Android 在相对布局中将滚动条添加到动态表视图

Android 在相对布局中将滚动条添加到动态表视图,android,tableview,android-scrollbar,Android,Tableview,Android Scrollbar,我已经在相对布局中动态创建了动态表布局。我正在动态添加文本视图。我有9个字段要显示。如何在其中放置水平和垂直滚动条 代码: 创建时受保护的void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_视图); //在操作栏中显示“向上”按钮。 setupActionBar(); TableLayout TableLayout=新的TableLayout(g

我已经在相对布局中动态创建了动态表布局。我正在动态添加文本视图。我有9个字段要显示。如何在其中放置水平和垂直滚动条

代码:

创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_视图);
//在操作栏中显示“向上”按钮。
setupActionBar();
TableLayout TableLayout=新的TableLayout(getApplicationContext());
TableRow TableRow;
文本视图文本视图;
............................
............................
............................
对于(int i=0;i
使顶层布局成为一个
滚动视图

scrollView.addView(tableLayout);
setContentView(scrollView);

像这样创建layout.xml文件

<RelativeLayout xmlns:ads="http://schemas.android.com/apk/res/com.smartcloud.podcast_he"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg_iphone" >
        <ScrollView
            android:id="@+id/ScrollView03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/headingtitle2" >

        </ScrollView>
 </RelativeLayout>

我是Android新手。事实上我已经试过了。它不起作用。你能告诉我应该把这个放在我的代码里的确切位置吗?太好了。它对垂直滚动条有效。我怎么能把水平滚动条放进去?
<RelativeLayout xmlns:ads="http://schemas.android.com/apk/res/com.smartcloud.podcast_he"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg_iphone" >
        <ScrollView
            android:id="@+id/ScrollView03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/headingtitle2" >

        </ScrollView>
 </RelativeLayout>
setContentView(R.layout.activity_view);
        // Show the Up button in the action bar.
setupActionBar();

ScrollView scrollview = (ScrollView) findViewById(R.id.ScrollView03);

TableLayout tableLayout = new TableLayout(getApplicationContext());
    TableRow tableRow;
        TextView textView;


       ............................
       ............................
       ............................
       for (int i = 0; i < rows; i++) 
        {                               //4 rows
        tableRow = new TableRow(getApplicationContext());

        for (int j = 0; j < columns; j++) 
        {                           //3 columns
            textView = new TextView(getApplicationContext());

            textView.setText(temp[k++]);
            textView.setPadding(15, 15, 15, 15);
            tableRow.addView(textView);

        }

        tableLayout.addView(tableRow);
    }
scrollview.addView(tableLayout );
    setContentView(scrollView);
    setContentView(tableLayout);