當前位置: 首頁>>代碼示例>>Java>>正文


Java PreferenceScreen.getPreference方法代碼示例

本文整理匯總了Java中android.preference.PreferenceScreen.getPreference方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceScreen.getPreference方法的具體用法?Java PreferenceScreen.getPreference怎麽用?Java PreferenceScreen.getPreference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.preference.PreferenceScreen的用法示例。


在下文中一共展示了PreferenceScreen.getPreference方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
	}
}
 
開發者ID:mniip,項目名稱:bananapeel,代碼行數:20,代碼來源:ServerPreferencesScreen.java

示例2: onCreate

import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	addPreferencesFromResource(R.xml.pref_infos);
	setHasOptionsMenu(true);

	findPreference("version").setSummary(getString(R.string.version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE));

	PreferenceScreen prefScreen = getPreferenceScreen();
	for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
		Preference pref = prefScreen.getPreference(i);
		if (!BuildConfig.DEBUG && pref.getKey().startsWith("debug_"))
			prefScreen.removePreference(pref);
	}

	if (BuildConfig.DEBUG) {
		findPreference("debug_send_notification").setSummary("Package name: " + BuildConfig.APPLICATION_ID);
		findPreference("debug_send_notification").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
			@Override
			public boolean onPreferenceClick(Preference preference) {
				((NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE)).notify(0,
						new NotificationCompat.Builder(getActivity())
								.setSmallIcon(R.drawable.info)
								.setContentTitle("Test Notification")
								.setContentText("Use " + BuildConfig.APPLICATION_ID + " as the package name to test your actions")
								.build());
				return true;
			}
		});
	}
}
 
開發者ID:SapuSeven,項目名稱:NotiCap,代碼行數:32,代碼來源:SettingsActivity.java

示例3: updateSelected

import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private void updateSelected() {
    final PreferenceScreen screen = getPreferenceScreen();
    final int count = screen.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        final Preference preference = screen.getPreference(index);
        if (preference instanceof KeyboardThemePreference) {
            final KeyboardThemePreference pref = (KeyboardThemePreference)preference;
            final boolean selected = (mSelectedThemeId == pref.mThemeId);
            pref.setSelected(selected);
        }
    }
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:13,代碼來源:ThemeSettingsFragment.java

示例4: setDescriptions

import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private void setDescriptions(PreferenceScreen screen)
{
	for(int i = 0; i < screen.getPreferenceCount(); i++)
	{
		Preference preference = screen.getPreference(i);
		setSingleDescription(preference);
		if(preference instanceof PreferenceScreen)
			setDescriptions((PreferenceScreen)preference);
	}
}
 
開發者ID:mniip,項目名稱:bananapeel,代碼行數:11,代碼來源:ServerPreferencesScreen.java

示例5: setDescriptions

import android.preference.PreferenceScreen; //導入方法依賴的package包/類
private void setDescriptions(PreferenceScreen screen)
{
	for(int i = 0; i < screen.getPreferenceCount(); i++)
	{
		Preference preference = screen.getPreference(i);
		if(preference instanceof EditTextPreference)
			preference.setSummary(((EditTextPreference)preference).getText());
		if(preference instanceof PreferenceScreen)
			setDescriptions((PreferenceScreen)preference);
	}
}
 
開發者ID:mniip,項目名稱:bananapeel,代碼行數:12,代碼來源:PreferencesScreen.java

示例6: onCreate

import android.preference.PreferenceScreen; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Bind the view with presenter
    presenter = new Presenter(this);
    presenter.getInitialize(getArguments());

    PreferenceScreen preferenceScreen = getPreferenceScreen();

    //START loop to set listener on Preferences
    // Set "this" to listen for all preference click/change listener for all preferences
    for (int i = 0, size = preferenceScreen.getPreferenceCount(); i < size; i++) {
        Preference preference = preferenceScreen.getPreference(i);
        preference.setOnPreferenceClickListener(this);
        preference.setOnPreferenceChangeListener(this);

        // If this is a preference category, make sure to go through all the subpreferences as well.
        if (preference instanceof PreferenceCategory) {
            Stack<PreferenceCategory> stack = new Stack<>();
            stack.push((PreferenceCategory) preference);

            do {
                PreferenceCategory category = stack.pop();
                for (int x = 0, xSize = category.getPreferenceCount(); x < xSize; x++) {
                    Preference subPref = category.getPreference(x);
                    subPref.setOnPreferenceChangeListener(this);
                    subPref.setOnPreferenceClickListener(this);

                    if (subPref instanceof PreferenceCategory) {
                        stack.push((PreferenceCategory) subPref);
                    }
                }
            }
            while (!stack.isEmpty());
        }
    } //END loop to set listener on Preferences

    //This will update the state of the Settings view
    presenter.handlePreferences();
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:42,代碼來源:SettingsFragment.java


注:本文中的android.preference.PreferenceScreen.getPreference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。