Friday, May 06, 2016

How to handle two Spinner onItemSelected() in Android


Use below code to differentiate the action of spinner



public void onItemSelected(AdapterView arg, View view,
int pos, long id) {

arg.getItemAtPosition(pos);

TextView tvReadValue = (TextView) findViewById(R.id.tvReadValue);
switch (arg.getId())
{
case R.id.spinDimension:

//Your code that deal with first spinner

break;

case R.id.speedDimension:

//Your code that deal with second spinner
break;
}

No comments: