Android Spinner, needs a menu for each item



First of all, I'm a beginner in android I have a spinner that needs specific menu for each item on the spinner. This is the basic spinner



<Spinner
android:id="@+id/building_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:spinnerMode="dialog" />


and these are the items on the spinner



<string-array name="building_types">
<item>W1</item>
<item>W2</item>
<item>S1</item>
<item>S2</item>
<item>S3</item>
<item>S4</item>
<item>S5</item>
<item>C1</item>
<item>C2</item>
<item>C3</item>
<item>PC1</item>
<item>PC2</item>
<item>RM1</item>
<item>RM2</item>
<item>URM</item>
</string-array>


and this is the class for the spinner



states = getResources().getStringArray(R.array.building_types);


spinner = (Spinner) findViewById(R.id.building_type);

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, states);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
//do what?
}

@Override
public void onNothingSelected(AdapterView<?> arg0) {

}
});


when an user choose an item on the spinner, i want some specific radio boxes comes out. basically, it is just like



if building_types=="w1"
then show radiobox1
elseif building_types=="w2"
then show radiobox2
and so on


all i have read on tuts is only toast some text after it got selected.


any tuts similiar to this case maybe? thanks.


No comments:

Post a Comment