is it possible to Set selected value of second select based on specific values chosen from first select in android?
I have two Tabbar, First is for the ApplicationTAB View and second is for the SettingTAB. Now i have to set the Sound On/Off from the SettingAtb. If i have selected the Sound On then on ApplicationTab there is sound to be Play. And if i have Selected Off then the Sound should not be play on the ApplicationTab. So what should i have to do to implement like this. And if it is开发者_如何转开发 possible then let me know how i can able to do this settings.
Please Help me regarding this logic.
Thanks. As Googling i got the proper word for it. I want to implement to set the ToggleButton Value from one tab to another tab to be affected. Means i want to set the Something like Sound On/off from one tab for the another tab. If there is any Demo Project then let me know.
From what I undertood from your question you are trying to pass a value between 2 activities according to my understanding. And your sound on/off should be stored in shared preferences so that you can later refer them when the app starts the next time.
This is a clear explanation of Shared Preferences from google. This will allow you to store data as long as the app is not deleted.
So when you set the sound on/off flag you can save it in the sharedpreferences and when you go back to the first tab, you can fetch the flag from shared preferences in the onCreate and do what is necessary for the sound.
Here is a simple tutorial from a SaiGeetha's blog
you can try this
getSharedPreferences(Settings.SHARED_PREFS_NAME, MODE_PRIVATE)..getString(PREF_NAME, defaultValue);
or use other type of storage
documentation here
You can have interface defined in the tab host class. Implement the interface and pass it to the settings tab. Call its callback method from the settings tab whenever the setting changes. In the callback implementation, stop/start the sound.
class tabhost
public interface soundSettingsCallback {
public void onSoundSettingsChanged(boolean bStop);
};
apptab.setSoundSettingCallback(new soundSettingsCallback {
public void onSoundSettingsChanged(boolean bStop) {
// stop/start sounds.
}
});
精彩评论