skinkmfk.blogg.se

Android studio spinner get selected index
Android studio spinner get selected index







  • Async Task : Can you wait for AsyncTask to complete.
  • Android | Minimum Required SDK, Target SDK, Compil.
  • do what you want to do with the selected field. My code looks like this.Ĭity_tOnItemSelectedListener(new void onItemSelected(AdapterView parent, View view, int position, long id) To bypass this, I tried to keep a counter to identify the first time SetOnItemSelectedListener is called, and handle it to do nothing. 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.

    android studio spinner get selected index

    Since the first entry is shown, the city_tOnItemSelectedListener identifies this as a selected item.

    android studio spinner get selected index

    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.









    Android studio spinner get selected index