Spinner item getting select on Activity start up
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(parent.getContext(), "The country is " +
position , Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> parent) {
return;
}
});
when activity start onItemSelected method getting called
I want when activity start there should be no toast message .Message should be displayed when user will select an item.
You have to use flag for maintaining that state. As your Activity starts the Spinner already has its first items as selected therefore its
onItemSelectedgets called on start up of the Activity.You can manage it by this, take two int variables.
Now when you initialize the spinner set
first_spinner = 1;then add the Listener