I am wondering is it possible to have 2 nested layouts in android? I have table layout in a scroll view. I want to add another layout type(not sure which one yet) but everyone I try crashes.
<?xml version="1.0" encoding开发者_运维问答="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
</TableLayout>
<TableLayout
android:id="@+id/tblLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
.... rows here ....
</TableLayout>
</ScrollView>
this will crash on the SetContentView(Resource.Layout.MyLayout);
"This is the next statement to execute when this thread returns from the current function."
If I just have one layout in the ScrollView it will load.
Scrollview documentation is sometimes interesting:
http://developer.android.com/reference/android/widget/ScrollView.html
Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.
As they suggest, you should put a LinearLayout that include both of your TableLayout
Try surrounding the two tables with a Layout like this;
<ScrollView>
<RelativeLayout>
<TableLayout>
</TableLayout>
<TableLayout>
</TableLayout>
<RelativeLayout>
</ScrollView>
精彩评论