user1222905
user1222905

Reputation: 519

android edittext and multiple checkboxes

I need an editText and 10 checkboxes. On android phone I also need to have a scrollview. I mean I need to see the checkboxez in a scroll. How to do that?

Can someone post an layout example?

Upvotes: 0

Views: 259

Answers (2)

MAC
MAC

Reputation: 15847

add all your component to scrollview

<ScrollView....>
<LinearLayout..>
    <EditText />
    <CheckBox />
    <CheckBox />
    <CheckBox />
    <CheckBox />
    .
    .
    </LinearLayout..>
</ScrollView>

Upvotes: 1

Shankar Agarwal
Shankar Agarwal

Reputation: 34765

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <EditText id ="@+id/edittext1"
 android:text="EditText 1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 />
 <ScrollView android:layout_width="fill_parent"
   android:layout_height="fill_parent">
 <LinearLayout 
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">
 <CheckBox android:id="@+id/check" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:text="@string/checkboxtest"/>
<CheckBox android:id="@+id/check" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:text="@string/checkboxtest"/>
<CheckBox android:id="@+id/check" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:text="@string/checkboxtest"/><CheckBox android:id="@+id/check" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:text="@string/checkboxtest"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

Upvotes: 1

Related Questions