![]() ![]() Hence it does not wait for the user to select anything, it simply assumes that Delhi is the choice from user and moves ahead in code. Since the first entry is shown, the city_tOnItemSelectedListener identifies this as a selected item. Spinner spinner = (Spinner) activity.findViewById(R.id.spinner) ĪrrayAdapter adapter = new ArrayAdapter(activity, android.R.layout.ArrayAdapter aa=new ArrayAdapter (getApplicationContext(),Ĭity_spinner = (Spinner) findViewById(R.id.spinner1) īy default Delhi, being the first entry in the ArrayList aa which is the adapter for the spinner, it is shown by the Spinner by default. Je pourrais juste ajouter un nouvel article "Select One" aux articles, mais alors "Select One" serait également affiché dans la liste déroulante en tant que premier article, ce qui n'est pas ce que je veux.Ĭe code a été testé et fonctionne sur Android 4.4 ![]() Spinner spinner = (Spinner) findViewById(R.id.mySpinner) ĪrrayAdapter adapter = new ArrayAdapter(this,Īndroid.R.layout.simple_spinner_item, items) ĪtDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) Īvec ce code, l'élément "One" est initialement affiché. J'ai le code suivant pour créer un Spinner: String items = new String Après que l'utilisateur a fait une sélection, l'élément sélectionné est affiché dans le Spinner au lieu de "Select One". Lorsque l'utilisateur clique sur le bouton rotatif, la liste des éléments s'affiche et l'utilisateur sélectionne l'une des options. ![]() ![]() Comment faire un Spinner Android avec le texte initial "Select One"ĭans Android, je veux utiliser un Spinner qui initialement (lorsque l'utilisateur n'a pas encore fait de sélection) affiche le texte "Select One". ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |