i have a basic information form with textfield, radiofield, and numberfield
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="Your Information"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center"/>
</TableRow>
<View
android:background="@drawable/barbell"
android:layout_width="fill_parent"
android:layout_height="30dip"/>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nickname: "
android:layout_weight="1"
android:textSize="18sp"
android:textColor="#333333"/>
<EditText
android:id="@+id/infoname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:hint="3 to 10 characters"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gender: "
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:textSize="18sp"
android:textColor="#333333"/>
<RadioGroup
android:id="@+id/inforadioGender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<RadioButton
android:id="@+id/inforadioM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Male"/>
<RadioButton
android:id="@+id/inforadioF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age: "
android:layout_weight="1" android:textSize="18sp" android:textColor="#333333"/>
<EditText
android:id="@+id/infoage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="5 to 99"
android:layout_weight="1"/>
</TableRow>
i used sharedpreference and its editor for passing the string and number..
but i badly need a tutorial or for beginner in the radio button?
is it possible to do without creating preferences.xml(which i don’t want to mess around yet)
RadioGroup has the methods
getCheckedRadioButtonId()andcheck(int id). So, if you want to save the views state, you could simply store the id of the selected radio button, which is an int and if you want to load your view again, you could call the check method and pass in the saved int to select the radio button again.