ScrollView仅支持一个子项,报错ScrollView can host only one direct child
来源:互联网 发布:redis 显示所有数据库 编辑:程序博客网 时间:2024/05/21 10:40
Android 2.3.3Eclipse Version: 3.7.0LogCat
LogCat 报错信息:
03-06 16:20:10.788: ERROR/AndroidRuntime(163): Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.widget.ScrollView.addView(ScrollView.java:229)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.view.LayoutInflater.rInflate(LayoutInflater.java:627)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.app.Activity.setContentView(Activity.java:1657)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at com.taobao.htc.manage.CopyRight.onResume(CopyRight.java:50)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.app.Activity.performResume(Activity.java:3832)03-06 16:20:10.788: ERROR/AndroidRuntime(163): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)03-06 16:20:10.788: ERROR/AndroidRuntime(163): ... 12 more
发生错误原因分析:
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 childException details are logged in Window > Show View > Error Log
- ScrollView仅支持一个子项,报错ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- scrollview can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView can host only one direct child
- ScrollView:ScrollView can host only one direct child异常
- 关于scrollview使用报错Exception raised during rendering: ScrollView can host only one direct child (Detail
- Android 控制台异常:ScrollView can host only one direct child
- android:ScrollView can host only one direct child
- ScrollView can host only one direct child 解决
- android 异常:ScrollView can host only one direct child
- Wce中的source文件中的RELEASETYPE类型
- 解决google打不开链接问题
- 内排序
- 编写一个组合鼠标事件和键盘事件的程序,该程序模拟一个电子白板,用户用鼠标在白板上画画,并通过键盘在上面写字
- Parallel Studio XE Windows*版
- ScrollView仅支持一个子项,报错ScrollView can host only one direct child
- Camera Face Detection
- C++容器通用算法
- java处理网络数据流
- 做人难
- 一年中的第几天
- JAVA 注解示例 详解
- strcpy实现
- 收藏的好的 blog