ScrollView in android
<p>I have a TableLayout, in which rows are dynamically created, thus it may cross the limited screen size. To avoid this I am trying to add a scroll view after creating the table layout as:</p>

<pre><code>TableLayout tl = (TableLayout) findViewById(R.id.tableLayout1);
ScrollView sv = new ScrollView(this);
tl.addView(sv);

for (i = 0; i &lt; count; i++) {
    TableRow tr = new TableRow(this); 
    .
    .
    .
    .  //finally iam adding this table row to layout.
    tl.addView(tr, new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    submit.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent myIntent = new Intent(getApplicationContext(),
            SmsActivity.class);
            // setMessageBody((String) tvf.getContentDescription());
            // submit.setEnabled(false);
            String messageText = (String)  valueTV.getText();
            String dateText = (String) labelTV.getText();
            myIntent.putExtra("messageText",dateText+"\n"+message);

            startActivity(myIntent);
        }});
}
</code></pre>

<p>However the application is getting force closed if the number of rows increases more than the size of display.</p>

<p>My log cat shows the error as </p>

<pre><code>06-28 14:41:49.533: ERROR/AndroidRuntime(1256): Caused by: java.lang.StringIndexOutOfBoundsException
</code></pre>

<p>What is the problem and how can I fix it?</p>
