ImI'm doing an androidAndroid app which can get data from a web service & loadedload it into spinner.I I need to maintain the selected data state of the spinner while I go to some screen & come back.For ex.if im For example, if I'm getting data from the web service as "1.apple 2.orange 3.grapes"1.apple 2.orange 3.grapes & loadedloading it into apinner.On that ithe spinner, then I select orangeorange.When i When I go to some other screen & come back.,the the selected spinner data should be orangeorange.But But it again loads data from the server into the spinner.Can Can anybody help me to resolve this? Thanks
My trycode:
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... if (Constants.SPINNER != null ) { spinner.setSelection( Constants.SPINNER); } else { //WebCall here for getting data// } } //... spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int arg2, long arg3) { Constants.SPINNER = spinner.getSelectedItemPosition(); In ConstantConstant class: public static Integer SPINNER="";
public static Integer SPINNER="";