From inside my activity, how do I know when my XML is done being inflated
<p>I am trying to add some objects to a ScrollView but I am getting a NULL POINTER EXCEPTION because I believe that the object has not been created yet from the method call setContentView which I assume launches some new threads to finish the task. How can I know when inflation is done from the Activities point of view. I do not want to extend ScrollView and override it's onFinishInflation method though.</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ScrollView v = (ScrollView)super.findViewById(R.id.scrollview);

    for(int i=0;i&lt;20;i++)
    {
        TextView tv = new TextView(this);
        tv.setText("Blah");
        v.addView(tv);
    }

}
</code></pre>
