Android 2.3.3 Eclipse Version: 3.7.0 LogCat
LogCat 报错信息:
发生错误原因分析:
ScrollView仅支持一个子项。
查看对应的layout xml,发现ScrollView中有两个子项。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="vertical"> <TextView android:id="@+id/textView2" android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/text_CRdesc_title"></TextView> <TextView android:id="@+id/textView2" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text_CRdesc"></TextView> </ScrollView>
解决办法:
在ScrollView 中设LinearLayout为子项 ,将其它View放入LinearLayout。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="vertical"> <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/textView2" android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/text_CRdesc_title"></TextView> <TextView android:id="@+id/textView2" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text_CRdesc"></TextView> </LinearLayout> </ScrollView>
PS. 在Error Log中有错误提示。但在编辑layout xml 时未开启“Error Log”窗口,未发现报错。
其实“Graphical Layout” 中也会有报错提示
ScrollView can host only one direct child Exception details are logged in Window > Show View > Error Log