title: How to retrieve listview focus in Android?
body: <p>I have a base adapter that works as class helper to set a custom listview. Now everything works fine except if I try to set another base adapter, The listview loses its focus of the item that I was on before setting it. I don’t know if there is a way that could help me to retrieve the same focus on the same item. Thank you very much in advance.</p>
  
  <p>This is my base adapter class:</p>
  
  <pre><code>    class CustomAdapterWithImages extends BaseAdapter {
  
      LayoutInflater mInflater;
  
  
      public CustomAdapterWithImages(){
          mInflater = (LayoutInflater) Home.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
      @Override
      public int getCount(){
          // TODO Auto-generated method stub
          return ids_list.size();//listview item count. 
      }
  
      @Override
      public Object getItem(int position){
          // TODO Auto-generated method stub
          return position; 
      }
  
      @Override
      public long getItemId(int position){
          // TODO Auto-generated method stub
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent){
          // TODO Auto-generated method stub
  
          ViewHolder vh;
  
          if (convertView == null) {
              convertView = mInflater.inflate(R.layout.layout_row, null);
              vh = new ViewHolder();
              convertView.setTag(vh);
             }else{
              vh = (ViewHolder) convertView.getTag();
             }            
  
          TextView book = (TextView) convertView.findViewById(R.id.listViewBookName);
          TextView writer = (TextView) convertView.findViewById(R.id.listViewWriterName);     
          ImageView image = (ImageView) convertView.findViewById(R.id.listViewImage);
  
          try{
              book.setText(names_list.get(position));
              writer.setText(writers_list.get(position));       
              image.setImageBitmap(thumbnails_list.get(position));
          }catch(IndexOutOfBoundsException e){
              e.printStackTrace();
          }
  
          return convertView;
      }
  
   class ViewHolder{
      TextView book, writer;
      ImageView image;
      }
  }   
  </code></pre>
  
  <p>By calling base adapter class I can set my listview as shown below:</p>
  
  <pre><code>listview.setAdapter(new CustomAdapterWithImages());    
  </code></pre>