title: Listview setOnItemClickListener - Not working for custom listview but working into simple listview
body: <p>I have problem with the get the <code>listview item</code> when click listitem.
  I Got <code>listview item</code> for the <code>simple listview</code>(Arrayadapter), but I have face problem for the <code>custom listview</code>.</p>
  
  <p>I am using </p>
  
  <pre><code>listview.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; myAdapter, View myView, int pos, long mylng) {
  
    //String  selectedFromList = (String) listview.getItemAtPosition(pos);
     String  selectedFromList = (String) adapter.getItem(pos);
  
      System.out.println("selected value &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;"+selectedFromList);
  
      SelectedAnswer.setAnswer(selectedFromList);
  
                }
  
            });
  </code></pre>
  
  <p>Into Logcat give me the <code>null</code> value :</p>
  
  <pre><code>I/System.out( 1238): selected value &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;null
  </code></pre>
  
  <p>main.class</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.quiz_questions);
  
          listview = (ListView) findViewById(R.id.questions_list);
  
          GoToNextQuestion();
    }
  
  private void GoToNextQuestion() {
      // TODO Auto-generated method stub
  
       currentGame = ((Quizapplication)getApplication()).getCurrentGame();
      currentQ = currentGame.getNextQuestion();
  
         setQuestions();
  
      listview.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; myAdapter, View myView, int pos, long mylng) {
  
    //String  selectedFromList = (String) listview.getItemAtPosition(pos);
     String  selectedFromList = (String) adapter.getItem(pos);
  
      System.out.println("selected value &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt; &gt;&gt;"+selectedFromList);
  
      SelectedAnswer.setAnswer(selectedFromList);
  
                }
  
            });
  
  
  }
  
   private void setQuestions() {
  
  
      // set the available options
      List&lt;String&gt; answers = currentQ.getQuestionOptions();
      System.out.println("value of the options &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;:"+answers); 
  
  
       //ArrayAdapter&lt; String&gt; myadapter = new ArrayAdapter&lt;String&gt;(getApplicationContext(), android.R.layout.simple_list_item_single_choice ,answers);
  
      //ArrayAdapter&lt; String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.quiz_questions_listitem, answers);        
  
               // working for the simple adapter
  
        adapter = new ListviewAdapter(this,answers);
  
       listview.setAdapter(adapter);
       //listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  }
  
  
   }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code> public class ListviewAdapter extends BaseAdapter{
  
  public List&lt;String&gt; Questions;  
  
  public Activity context;  
  public LayoutInflater inflater;
  
  
  public ListviewAdapter(Activity context,List&lt;String&gt; answers) {  
      super();  
  
      this.context = context;  
      this.Questions = answers;  
  
      this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  }  
  
  @Override  
  public int getCount() {  
      // TODO Auto-generated method stub  
      return Questions.size();  
  }  
  
  @Override  
  public Object getItem(int position) {  
      // TODO Auto-generated method stub  
      return null;  
  }  
  
  @Override  
  public long getItemId(int position) {  
      // TODO Auto-generated method stub  
      return 0;  
  }  
  
  public static class ViewHolder  
  {  
  
      TextView txtquestion;  
  }  
  
  @Override  
  public View getView(int position, View convertView, ViewGroup parent) {  
      // TODO Auto-generated method stub  
  
      ViewHolder holder;  
      if(convertView==null)  
      {  
          holder = new ViewHolder();  
          convertView = inflater.inflate(R.layout.quiz_questions_listitem, null);  
  
  
          holder.txtquestion = (TextView) convertView.findViewById(R.id.textView_option);  
  
          convertView.setTag(holder);  
  
        /*  convertView.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
  
                   System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+v.toString());
                  notifyDataSetChanged();
  
                   SelectedAnswer.setAnswer(v.toString());
              }
          });*/
      }  
      else  
          holder=(ViewHolder)convertView.getTag();  
  
      holder.txtquestion.setText(Questions.get(position));  
  
      return convertView;  
  }   
  
  }
  </code></pre>