Android : Focus on Spinner not Work

on Thursday, April 2, 2015


I have a spinner in my activity and i want that it open the select menu as soon as the activity starts


This is my layout excerpt that the Spinner appears



<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#fff"
android:layout_weight="5">

<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:prompt="@string/app_name"
android:gravity="center_vertical"/>

</LinearLayout>


And this is my class that should open the Menu



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

spn.setFocusable(true);
spn.setFocusableInTouchMode(true);

spn.requestFocus();

0 comments:

Post a Comment