krishna krishna - 8 months ago 67
Android Question

problems in android spinner

I want to display messages based on selection of value from spinner.
so i used folowing code.

String ar[]={"hello","abc"};
ArrayAdapter<String> adapt=new ArrayAdapter<String>(SpinnerEampleActivity.this, android.R.layout.simple_spinner_dropdown_item,ar);
sp.setOnItemSelectedListener(new OnItemSelectedListener() {

public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3)
AlertDialog.Builder alert=new AlertDialog.Builder(SpinnerEampleActivity.this);
AlertDialog.Builder alert=new AlertDialog.Builder(SpinnerEampleActivity.this);


but if i select the already selected value from spinner i am not getting any message.
could any help me to solve the problem.
Thanks in advance.

Answer Source

When you clicks again the currently selected item, then it can not fire any event. So you can not catch setOnItemSelectedListener for spinner to respond.

You need to create your custom spinner adapter to handle the click for the already selected item.