Reputation: 55
There have two RadioButton, Twelve Checkbox and one send button,each button has a custom selector. RadioButton and Checkbox out of range, can not let all RadioButton and Checkbox in the android xml layout. I used ScrollView, but it have some error about "Exception raised during rendering: ScrollView can host only one direct child". I don't know how can RadioButton and Checkbox in there range. How to change RadioButton and CheckBox in to the RadioButton in there range? thanks.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/etIdUserName2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/etIdUseracc2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/etIdPassre2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者性別"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<RadioButton
android:id="@+id/boy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男" />
<RadioButton
android:id="@+id/girl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者年齡"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<CheckBox
android:id="@+id/under"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="18以下"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="23~27"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18~23"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="28~32"
android:textSize="15sp" />
<CheckBox
android:id="@+id/up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="32以上"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者興趣"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<CheckBox
android:id="@+id/girluse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="女裝與服飾配件、女包精品與女鞋"
android:textSize="15sp" />
<CheckBox
android:id="@+id/makeup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="美容保養與彩妝"
android:textSize="15sp" />
<CheckBox
android:id="@+id/boyuse"
android:layout_width="152dp"
android:layout_height="wrap_content"
android:text="男性精品與服飾"
android:textSize="15sp" />
<CheckBox
android:id="@+id/electronicproduct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="電腦、平板與周邊"
android:textSize="15sp" />
<CheckBox
android:id="@+id/cellphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="手機、配件與通"
android:textSize="15sp" />
<CheckBox
android:id="@+id/food"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="美食與地方特產"
android:textSize="15sp" />
<CheckBox
android:id="@+id/Stationery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="文具與事務用"
android:textSize="15sp" />
<Button
android:id="@+id/setbutton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送出"
android:textSize="15sp" />
</ScrollView>
</LinearLayout>
Upvotes: 1
Views: 530
Reputation: 4868
"ScrollView can host only one direct child".
So simply wrap everything in a LinearLayout
.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/etIdUserName2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/etIdUseracc2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/etIdPassre2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者性別"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<RadioButton
android:id="@+id/boy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男" />
<RadioButton
android:id="@+id/girl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者年齡"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<CheckBox
android:id="@+id/under"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="18以下"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="23~27"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18~23"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="28~32"
android:textSize="15sp" />
<CheckBox
android:id="@+id/up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="32以上"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者興趣"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<CheckBox
android:id="@+id/girluse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="女裝與服飾配件、女包精品與女鞋"
android:textSize="15sp" />
<CheckBox
android:id="@+id/makeup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="美容保養與彩妝"
android:textSize="15sp" />
<CheckBox
android:id="@+id/boyuse"
android:layout_width="152dp"
android:layout_height="wrap_content"
android:text="男性精品與服飾"
android:textSize="15sp" />
<CheckBox
android:id="@+id/electronicproduct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="電腦、平板與周邊"
android:textSize="15sp" />
<CheckBox
android:id="@+id/cellphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="手機、配件與通"
android:textSize="15sp" />
<CheckBox
android:id="@+id/food"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="美食與地方特產"
android:textSize="15sp" />
<CheckBox
android:id="@+id/Stationery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="文具與事務用"
android:textSize="15sp" />
<Button
android:id="@+id/setbutton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送出"
android:textSize="15sp" />
</LinearLayout>
</ScrollView>
Upvotes: 2
Reputation: 10877
As per the Logcat says Exception raised during rendering: ScrollView can host only one direct child
. One can have only one direct child view to ScrollView
. As you have so many check boxes and RadioButton inside ScrollView
it throws an error.
You just need to add all your Checkbox
and RadioButton
inside View
with ParentView as ScrollView
which can handle all your RadioButton
and Checkboxes
. In here I've added Linearlayout
as ParentView
for all your Checkboxes
and RadioButton
.
Explaination:
ScrollView // ParentView
LinearLayout // DirectChild of ScrollView
RadioButton & Checkboxes // Direct child of LinearLayout
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/etIdUserName2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/etIdUseracc2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:id="@+id/etIdPassre2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者性別"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<RadioButton
android:id="@+id/boy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男" />
<RadioButton
android:id="@+id/girl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者年齡"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<CheckBox
android:id="@+id/under"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="18以下"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="23~27"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18~23"
android:textSize="15sp" />
<CheckBox
android:id="@+id/between3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="28~32"
android:textSize="15sp" />
<CheckBox
android:id="@+id/up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="32以上"
android:textSize="15sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="使用者興趣"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp" />
<CheckBox
android:id="@+id/girluse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="女裝與服飾配件、女包精品與女鞋"
android:textSize="15sp" />
<CheckBox
android:id="@+id/makeup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="美容保養與彩妝"
android:textSize="15sp" />
<CheckBox
android:id="@+id/boyuse"
android:layout_width="152dp"
android:layout_height="wrap_content"
android:text="男性精品與服飾"
android:textSize="15sp" />
<CheckBox
android:id="@+id/electronicproduct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="電腦、平板與周邊"
android:textSize="15sp" />
<CheckBox
android:id="@+id/cellphone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="手機、配件與通"
android:textSize="15sp" />
<CheckBox
android:id="@+id/food"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="美食與地方特產"
android:textSize="15sp" />
<CheckBox
android:id="@+id/Stationery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="文具與事務用"
android:textSize="15sp" />
<Button
android:id="@+id/setbutton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="送出"
android:textSize="15sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Upvotes: 1