本文整理汇总了Java中android.preference.PreferenceScreen类的典型用法代码示例。如果您正苦于以下问题:Java PreferenceScreen类的具体用法?Java PreferenceScreen怎么用?Java PreferenceScreen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PreferenceScreen类属于android.preference包,在下文中一共展示了PreferenceScreen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreferenceTreeClick
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (preference == mPowerSoundsVibrate) {
CMSettings.Global.putInt(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE,
mPowerSoundsVibrate.isChecked() ? 1 : 0);
} else if (preference == mPowerSoundsRingtone) {
launchNotificationSoundPicker(REQUEST_CODE_POWER_NOTIFICATIONS_RINGTONE,
CMSettings.Global.getString(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE));
} else {
// If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
return true;
}
示例2: onPreExecute
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
protected void onPreExecute() {
autoExpandFolder = (ListPreference) findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
autoExpandFolder.setEnabled(false);
archiveFolder = (ListPreference) findPreference(PREFERENCE_ARCHIVE_FOLDER);
archiveFolder.setEnabled(false);
draftsFolder = (ListPreference) findPreference(PREFERENCE_DRAFTS_FOLDER);
draftsFolder.setEnabled(false);
sentFolder = (ListPreference) findPreference(PREFERENCE_SENT_FOLDER);
sentFolder.setEnabled(false);
spamFolder = (ListPreference) findPreference(PREFERENCE_SPAM_FOLDER);
spamFolder.setEnabled(false);
trashFolder = (ListPreference) findPreference(PREFERENCE_TRASH_FOLDER);
trashFolder.setEnabled(false);
if (!isMoveCapable) {
PreferenceScreen foldersCategory =
(PreferenceScreen) findPreference(PREFERENCE_CATEGORY_FOLDERS);
foldersCategory.removePreference(archiveFolder);
foldersCategory.removePreference(spamFolder);
foldersCategory.removePreference(draftsFolder);
foldersCategory.removePreference(sentFolder);
foldersCategory.removePreference(trashFolder);
}
}
示例3: onActivityCreated
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mHavePrefs) {
bindPreferences();
}
mInitDone = true;
if (savedInstanceState != null) {
Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG);
if (container != null) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
preferenceScreen.restoreHierarchyState(container);
}
}
}
}
示例4: onCreate
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_theme);
final PreferenceScreen screen = getPreferenceScreen();
final Context context = getActivity();
final Resources res = getResources();
final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
for (int index = 0; index < keyboardThemeNames.length; index++) {
final KeyboardThemePreference pref = new KeyboardThemePreference(
context, keyboardThemeNames[index], keyboardThemeIds[index]);
screen.addPreference(pref);
pref.setOnRadioButtonClickedListener(this);
}
final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
mSelectedThemeId = keyboardTheme.mThemeId;
}
示例5: onPreferenceTreeClick
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference)
{
boolean result =
super.onPreferenceTreeClick(preferenceScreen, preference);
// Set home as up
if (preference instanceof PreferenceScreen)
{
Dialog dialog = ((PreferenceScreen)preference).getDialog();
ActionBar actionBar = dialog.getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
}
return result;
}
示例6: init
import android.preference.PreferenceScreen; //导入依赖的package包/类
/**
* Initialize internal states of this object.
*
* @param context the context for this application.
* @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
* @return true if this application is an IME and has two or more subtypes, false otherwise.
*/
public boolean init(final Context context, final PreferenceScreen prefScreen) {
mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
mImi = getMyImi(context, mImm);
if (mImi == null || mImi.getSubtypeCount() <= 1) {
return false;
}
final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
mSubtypeEnablerPreference = new Preference(context);
mSubtypeEnablerPreference.setIntent(intent);
prefScreen.addPreference(mSubtypeEnablerPreference);
updateSubtypeEnabler();
return true;
}
示例7: getPreferenceList
import android.preference.PreferenceScreen; //导入依赖的package包/类
/**
* Gets the list of preferences in a PreferenceScreen
*
* @param p preference to add to the list
* @param list of preferences in the PreferenceScreen
* @return a list of all the preferences
*/
private ArrayList<Preference> getPreferenceList(Preference p, ArrayList<Preference> list) {
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
PreferenceGroup prefGroup = (PreferenceGroup) p;
final int prefCount = prefGroup.getPreferenceCount();
for (int i = 0; i < prefCount; i++) {
getPreferenceList(prefGroup.getPreference(i), list);
}
}
if (!(p instanceof PreferenceCategory)) {
list.add(p);
}
return list;
}
示例8: setKeys
import android.preference.PreferenceScreen; //导入依赖的package包/类
private void setKeys(PreferenceScreen screen)
{
for(int i = 0; i < screen.getPreferenceCount(); i++)
{
Preference preference = screen.getPreference(i);
String key = server + ";" + preference.getKey();
preference.setKey(key);
if(preference instanceof EditIntPreference)
((EditIntPreference)preference).setInt(preference.getSharedPreferences().getInt(key, -1));
else if(preference instanceof EditTextPreference)
((EditTextPreference)preference).setText(preference.getSharedPreferences().getString(key, null));
else if(preference instanceof ListPreference)
((ListPreference)preference).setValue(preference.getSharedPreferences().getString(key, null));
else if(preference instanceof CheckBoxPreference)
((CheckBoxPreference)preference).setChecked(preference.getSharedPreferences().getBoolean(key, false));
if(preference instanceof PreferenceScreen)
setKeys((PreferenceScreen)preference);
}
}
示例9: onCreate
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_wireless_socket);
setHasOptionsMenu(true);
PreferenceScreen preferenceScreen = this.getPreferenceScreen();
PreferenceCategory preferenceCategory = new PreferenceCategory(preferenceScreen.getContext());
preferenceCategory.setTitle("Wireless sockets");
preferenceScreen.addPreference(preferenceCategory);
for (int index = 0; index < WirelessSocketService.getInstance().GetDataList().getSize(); index++) {
WirelessSocket wirelessSocket = WirelessSocketService.getInstance().GetDataList().getValue(index);
SwitchPreference preference = new SwitchPreference(preferenceScreen.getContext());
preference.setTitle(wirelessSocket.GetName());
preference.setKey(wirelessSocket.GetSettingsKey());
preference.setDefaultValue(false);
preferenceCategory.addPreference(preference);
bindPreferenceSummaryToValue(preference);
}
}
示例10: onPreferenceTreeClick
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
final String key = preference.getKey();
switch (key) {
case KEY_CHECK_UPDATE:
mTask = CheckUpdateTask.getInstance(false);
if (!mTask.getStatus().equals(AsyncTask.Status.RUNNING)) {
mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
}
return true;
case KEY_CHANGELOG:
ChangelogFragment changelogFrag = new ChangelogFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
transaction.replace(this.getId(), changelogFrag);
transaction.addToBackStack(this.getClass().getName());
transaction.commit();
return true;
default:
OTALink link = LinkConfig.getInstance().findLink(key, getActivity());
if (link != null) {
OTAUtils.launchUrl(link.getUrl(), getActivity());
}
break;
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
示例11: onCreate
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
addPreferencesFromResource(R.xml.ota);
mRomInfo = (PreferenceScreen) getPreferenceScreen().findPreference(KEY_ROM_INFO);
mCheckUpdate = (PreferenceScreen) getPreferenceScreen().findPreference(KEY_CHECK_UPDATE);
mUpdateInterval = (ListPreference) getPreferenceScreen().findPreference(KEY_UPDATE_INTERVAL);
if (mUpdateInterval != null) {
mUpdateInterval.setOnPreferenceChangeListener(this);
}
mLinksCategory = (PreferenceCategory) getPreferenceScreen().findPreference(CATEGORY_LINKS);
}
示例12: updateLinks
import android.preference.PreferenceScreen; //导入依赖的package包/类
private void updateLinks(boolean force) {
List<OTALink> links = LinkConfig.getInstance().getLinks(getActivity(), force);
for (OTALink link : links) {
String id = link.getId();
PreferenceScreen linkPref = (PreferenceScreen) getPreferenceScreen().findPreference(id);
if (linkPref == null && mLinksCategory != null) {
linkPref = getPreferenceManager().createPreferenceScreen(getActivity());
linkPref.setKey(id);
mLinksCategory.addPreference(linkPref);
}
if (linkPref != null) {
String title = link.getTitle();
linkPref.setTitle(title.isEmpty() ? id : title);
linkPref.setSummary(link.getDescription());
}
}
}
示例13: resetList
import android.preference.PreferenceScreen; //导入依赖的package包/类
private void resetList() {
getPreferenceScreen().removeAll();
addPreferencesFromResource(R.xml.usb_device_preferences);
PreferenceScreen preferenceScreen = getPreferenceScreen();
Preference header = preferenceScreen.findPreference(PREF_OBJECT_NAME);
header.setTitle(mUsbInfo.getName());
header.setOnPreferenceClickListener(this);
for (int i = 0; i < mSites.size(); ++i) {
Website site = mSites.get(i);
Preference preference = new WebsitePreference(getActivity(), site, mCategory);
preference.getExtras().putSerializable(SingleWebsitePreferences.EXTRA_SITE, site);
preference.setFragment(SingleWebsitePreferences.class.getCanonicalName());
preferenceScreen.addPreference(preference);
}
// Force this list to be reloaded if the activity is resumed.
mSites = null;
}
示例14: clearStoredData
import android.preference.PreferenceScreen; //导入依赖的package包/类
private void clearStoredData() {
mSite.clearAllStoredData(
new Website.StoredDataClearedCallback() {
@Override
public void onStoredDataCleared() {
PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removePreference(
preferenceScreen.findPreference(PREF_CLEAR_DATA));
if (!hasUsagePreferences()) {
preferenceScreen.removePreference(
preferenceScreen.findPreference(PREF_USAGE));
}
popBackIfNoSettings();
}
});
}
示例15: onPreferenceTreeClick
import android.preference.PreferenceScreen; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference)
{
Log.v(L.TAG, "onPreferenceTreeClick() for key " + preference.getKey());
if("backupDb".equals(preference.getKey()))
{
// TODO dialog: This will backup you current SimplyDo database. You
// can access and manage these backups through mass storage
// access to you device. Make backup now to the file ....
backupDbSelected();
}
else if("restoreDb".equals(preference.getKey()))
{
Intent restoreActivity = new Intent(getBaseContext(), RestoreActivity.class);
startActivity(restoreActivity);
}
// the android docs give no clues as to what the returned bool does
return super.onPreferenceTreeClick(preferenceScreen, preference);
}