Skip to content Skip to sidebar Skip to footer

Android: How To Get Value From Spinner, And Based On Value To Redirect To Another Page

I am new to android. I am stuck with the spinner. There are two spinner item 'FROM' and 'TO'. I want to code as..if I want to search FROM Place1, To Place2. Then after clicking but

Solution 1:

use this one

spinner.setOnItemSelectedListener(newSpinner.OnItemSelectedListener() {
@OverridepublicvoidonItemSelected(AdapterView<?> main, View view, int position,
            long Id) {
            if(position==0){
            //your code
             }
             if(position==1){
            //your code
             }
    }
}

Solution 2:

use this-

if(str1.equals("plot16")&&str2.equals("plot17")){
          //do functionality
              }

Solution 3:

if (str1.equals( plot31) && str2.equals(plot314))
        {
            Intent i = new Intent(SelectLocation.this, Route1.class);
            startActivity(i);

        }

try this. == is used to compare the references whereas equals() method is used to compare values.

Post a Comment for "Android: How To Get Value From Spinner, And Based On Value To Redirect To Another Page"