Here is screenshot ...my changes in spinner value reflects only after 2 swipes I have an app with 10 screens and i have 1 spinner in my main activity and a textbox in fragment .I want to display the recently selected spinner value in my textbox .
I wrote a code to display the selected spinner value in my text box and its become stable throughout all my screens.But i don't know how to dynamically change the text box value according to the recently selected spinner value. (Before downvoting kindly suggest me some solutions)
Here is code to get the spinner value
String pos = (String) spinner.getSelectedItem();
SharedPreferences sharedPref = getSharedPreferences("Mode", Activity.MODE_PRIVATE);
SharedPreferences.Editor prefEditor = sharedPref.edit();
prefEditor.putString("userChoicemode", pos);
prefEditor.commit();
Here is the code to retrieve it
TextView modeselect = (TextView) view.findViewById(R.id.pass);
SharedPreferences sharedPref = this.getActivity().getSharedPreferences("Mode", Activity.MODE_PRIVATE);
String get = sharedPref.getString("userChoicemode",selected);
modeselect.setText("" + get);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…