ListView.getChildAt(validPosition) returns null
<p>When user clicks on item of ListView I show Edit button at this item of list. <code>lastSelectedPosition</code> has the position of the list item that was clicked last.                                                                                              </p>

<p>code:</p>

<pre><code>public class MainActivity extends Activity {
    private ListView listView;
    private MyAdapter adapter;

    // static - If the activity is re-created, the data
    // about list items remain.
    private static List&lt;String&gt; items = loadItems();

    private MyItemClickListener listener = new MyItemClickListener();
    private int lastSelectedPosition = ListView.INVALID_POSITION;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        listView = (ListView) findViewById(R.id.myListView);
        adapter = new MyAdapter(R.layout.my_item, items);
        listView.setAdapter(adapter);
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setOnItemClickListener(listener);

        if (savedInstanceState != null) {
            // Is recreating the activity because 
            // of the change screen orientation. 

            lastSelectedPosition = savedInstanceState.getInt("lastSelectedPos");
            if (lastSelectedPosition != ListView.INVALID_POSITION) {
                // !!! getChildAt() always returns null !!!
                View listItem = listView.getChildAt(lastSelectedPosition);
                View editButton = listItem.findViewById(R.id.editButton);

                // Only selected list item has visible EditButton, 
                // other list items have not
                editButton.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        // Is destroying the activity because 
        // of the change screen orientation.

        outState.putInt("lastSelectedPos", lastSelectedPosition);               
    }

    // Other methods
}
</code></pre>

<p>I think that <code>getChildAt()</code> always returns <code>null</code> in <code>Activity.onCreate()</code>, because at that moment the list is not yet fully developed. How I can get <code>View</code> of list item to show Edit button on it?</p>

<p>And sorry for my English.</p>

<p>Thanks</p>
