Set Visibility Of Textview From Different Layout Not Working Android
Im using spinner to hide textview from different layout/xml but my code is not working and Im stuck on this :( LayoutInflater layoutInflater = (LayoutInflat
Solution 1:
You could use shared preferences.
Set the Shared Preference(s) in the spinner's OnItemSelect listener; and retrieve them in the respective activity.
The following code, from How to set a default value to SharedPreferences programmatically?, is an example for setting the SharedPreference(s) :-
SharedPreferencesprefs= getActivity().getSharedPreferences(
PREFS_NAME, 0);
if (prefs.getInt("key_weight", null) == null) {
Editoreditor= prefs.edit();
editor.putInt("key_weight", 75);
editor.commit();
}
The following code is an example of retrieving from the SharedPreferences :-
SharedPreferencessp= PreferenceManager.getDefaultSharedPreferences(this);
finalbooleandevmode= sp.getBoolean(getResources().getString(R.string.sharedpreferencekey_developermode),false);
Noting that R.string.sharedpreferencekey_developermode holds the Shared Preferences Key Name
Post a Comment for "Set Visibility Of Textview From Different Layout Not Working Android"