android - creating scrollable spinner to show some items -
i used spinner show items works when items less 5 items, , when want show 10 items error happens : unfortunately stopped :( how can use scrollable spinner show items in spinner here is: spinner.xml :and main
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/shw" android:orientation="vertical" > <textview android:id="@+id/txt3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" android:text="which" android:textcolor="#ffffff" /> <linearlayout android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="wrap_content"> <button android:id="@+id/bt1help2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/spinner01" android:layout_marginright="100dp" android:layout_toleftof="@+id/txt3" android:text="ok" android:textcolor="#ffffff" /> <button android:id="@+id/btn2help2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="no" android:textcolor="#ffffff" /> </linearlayout> <spinner android:id="@+id/spinner01" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:verticalscrollbarposition="left" android:scrollbarthumbvertical="@drawable/scrollbar_style" android:layout_below="@+id/linearlayout1" android:layout_margintop="22dp" />
final dialog dl = new dialog(main.this); dl.setcontentview(r.layout.spinner); dl.settitle("show"); textview txt2 = (textview) dl.findviewbyid(r.id.txt2); textview txt3 = (textview) dl.findviewbyid(r.id.txt3); ///تنظیم متن txt2.settext(" 1 want show?"); button btn1help2 = (button) dl.findviewbyid(r.id.bt1help2); btn1help2.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { string array_spinner[]; array_spinner=new string[5]; array_spinner[0]="letter_one"; array_spinner[1]="letter_2"; array_spinner[2]="letter_3"; array_spinner[3]="letter_4"; array_spinner[4]="letter_5"; array_spinner[5]="letter_6"; array_spinner[6]="letter_7"; array_spinner[7]="letter_8"; array_spinner[8]="letter_9"; array_spinner[9]="letter_10"; spinner s = (spinner) dl.findviewbyid(r.id.spinner01); arrayadapter adapter = new arrayadapter(getapplicationcontext(),android.r.layout.simple_spinner_item, array_spinner); s.setadapter(adapter);
how can change scrollable spinner?
thanks answers
you can use scrollview. put relativelayout
inside scrollview
because can have 1 child.
<scrollview> <relativelayout> .... other views </relativelayout> </scrollview>
Comments
Post a Comment