title: Android ListView with a Custom Adapter - getChildAt() returns null
body: <p>I have a ListView with a Custom Adapter, and I need to access the View of individual rows of this ListView. I am trying to do it using getChildAt(), but it is returning null.</p>
  
  <p>Here's my ListView:</p>
  
  <pre><code>myListView = (ListView) findViewById (R.id.listViewLayout);
  </code></pre>
  
  <p>This is the custom adapter:</p>
  
  <pre><code>    public class MyListAdapter extends BaseAdapter {
         ...
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              if (convertView == null) {
                  LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  convertView = inflater.inflate(R.layout.list_row_layout, parent, false);
              }
              ...
      }
  </code></pre>
  
  <p>I create a List, and set it for the ListView:</p>
  
  <pre><code>List &lt;String&gt; myList = new ArrayList&lt;String&gt;();
  myList.add("entry 1");
  myList.add("entry 2");
  myList.add("entry 3");
  MyListAdapter myListAdapter = new MyListAdapter(getApplicationContext(), myList);
  myListView.setAdapter(myListAdapter);
  </code></pre>
  
  <p>Now, I want to access the View for individual rows.</p>
  
  <pre><code>View v = myListView.getChildAt(myListView.getFirstVisiblePosition());
  </code></pre>
  
  <p>This v is null, no matter what. Additionally, <code>myListView.getChildCount()</code> always returns null.</p>
  
  <p>What am I missing? Do I need to add the <code>convertView</code> to <code>parent</code> in <code>getView()</code>? Am I passing wrong parameters to <code>inflate</code>?</p>
  
  <p>I have struggled a lot to figure this out. Please help me!</p>
  
  <p>EDIT: I am posting the MyListAdapter class:</p>
  
  <pre><code>public class MyListAdapter extends BaseAdapter {
  
      private Context context;
      private List&lt;String&gt; myList;
  
      public MyListAdapter(Context c, List&lt;String&gt; m) {
          context = c;
          myList = m;
      }
  
      @Override
      public int getCount() {
          return myList.size();
      }
  
      @Override
      public Object getItem(int position) {
          return myList.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          final int pos = position;
  
          if (convertView == null) {
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = inflater.inflate(R.layout.list_row_layout, parent, false);
          }
  
              TextView text = (TextView) convertView.findViewById(R.id.itemText);
              text.setText(myList.get(pos));
  
              // Set the onClick Listener on this button
              Button rowButton = (Button) convertView.findViewById(R.id.itemButton);
  
              //commenting next two lines makes the list row clickable
              rowButton.setFocusableInTouchMode(false);
              rowButton.setFocusable(false);
  
              rowButton.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View v) {
                      Toast.makeText(context, myList.get(pos), Toast.LENGTH_SHORT).show();
                  } 
              });  
              convertView.setTag(pos);
              return convertView;
      }
  }
  </code></pre>