Developer
Developer

Reputation: 157

How can Check the condition of the two spinner?

How can Check the condition of the two spinner?

I have two spinners in my project. I want to write unit conversion project How can the different conditions of the selected spinners item Understand ?

Similar to the image below:

https://i.sstatic.net/fjURS.png

Upvotes: 6

Views: 573

Answers (1)

netpork
netpork

Reputation: 554

firstSpinner.setOnItemSelectedListener(this);
secondSpinner.setOnItemSelectedListener(this);

@Override
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
    Spinner spinner = (Spinner) parent;

    switch (spinner.getId()) {
    case R.id.first_spinner:
        // item selected on the first spinner
        // use position
        break;
    case R.id.second_spinner:
        // item selected on the second spinner
        // use position
        break;

    default:
        break;
    }
}

Upvotes: 2

Related Questions