title: How to create scroll view programmatically?
body: <p>I want to create scroll view with text view inside it programmatically. My code is like below. It works, but when I do getLayoutParams in onSizeChanged, I get InvocationTargetException. What is wrong with my code?</p>
  
  <pre><code>public MyActivity extends Activity 
    {
      public void onCreate(Bundle savedInstanceState) 
      {       
          super.onCreate(savedInstanceState);
          setContentView(new MyLayout(this));
      }
      protected class MyLayout extends RelativeLayout 
       {
          TextView tv;
          public MyLayout(Context context)
          {
             super(context);
             ScrollView sv = ScrollView(context);
             tv = new TextView(context);
             tv.setText("Hello World");
             sv.addView(tv);
             addView(sv);
          }
          protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld)
          {
              LayoutParams params = (LayoutParams)tv.getLayoutParams(); // I have          InvocationTargetException here. What's wrong?
          }   
      }
  }
  </code></pre>