Posted By

variable3 on 04/27/11


Tagged

radio buttons group Spinner


Versions (?)

Android Spinner, Group Radio Buttons


 / Published in: Java
 

  1. In xml----<Spinner android:id="@+id/spnState" android:layout_width="wrap_content" android:layout_height="wrap_content"></Spinner>
  2.  
  3.  
  4. String[] items = new String[] {"Karnataka", "Orissa", "Andhrapradesh"};
  5. Spinner spinner;
  6.  
  7. spinner = (Spinner)this.findViewById(R.id.spnState);
  8. ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, items);
  9. adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  10. spinner.setAdapter(adapter);
  11.  
  12.  
  13. How to group radio buttons--
  14. ==========================
  15. <RadioGroup
  16. android:layout_width="fill_parent"
  17. android:layout_height="wrap_content"
  18. android:orientation="vertical">
  19. <RadioButton android:text="Female" android:id="@+id/rdbFemale" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
  20. <RadioButton android:text="Male" android:id="@+id/rdbMale" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
  21. </RadioGroup>

Report this snippet  

You need to login to post a comment.