android - Spinner not getting populated with the given string array -
i have make android app. counting bunks college students. want make this:
spinner 1 has
select branch
- me
- ce
- it
- ee
select semester
1st
2nd
3rd
4th
etc.
now if student selecting me , 3rd semester, 3rd semester subjects should come like:
enter bunks of subject:
abc1: edittext
abc2: edittext
abc3: edittext
abc4: edittext
abc4: edittext
and input user should come logic of percentage of attendance, , answers should come on page same subject name.
can me please?
edit
my main.xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <spinner android:id="@+id/spinner1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout>
xml spinner:
<spinner android:id="@+id/city_spinner_iwant" android:layout_width="fill_parent" android:layout_height="wrap_content" android:prompt="@string/cityspinner" android:textcolor="@color/white" android:textsize="20dp" />
in code, set adapter populate spinner requires items (in case branches):
string[] city_array = new string[]{"london", "newyork", "paris"}; arrayadapter<string> cityarrayadapter = new arrayadapter<string>(this,android.r.layout.simple_spinner_item,city_array); city_spinner = (spinner) findviewbyid(r.id.city_spinner_iwant); city_spinner.setadapter(cityarrayadapter);
then show forms depending on item selected in spinner:
city_spinner.setonitemselectedlistener(new adapterview.onitemselectedlistener() { public void onitemselected(adapterview<?> adapter, view v,int i, long lng) { selected_city = adapter.getitematposition(i).tostring(); toast.maketext(getapplicationcontext(), selected_city, 1000).show(); //conditions depending on selected_city (in case selected branch) } public void onnothingselected(adapterview<?> arg0) { //no need impement } });
Comments
Post a Comment