Java PreferenceScreen.getPreference方法代码示例

本文整理汇总了Java中android.preference.PreferenceScreen.getPreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceScreen.getPreference方法的具体用法?Java PreferenceScreen.getPreference怎么用?Java PreferenceScreen.getPreference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.preference.PreferenceScreen的用法示例。


Java PreferenceScreen.getPreference方法代码示例

在下文中一共展示了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

本文标签属性:

示例:示例图

代码:代码是什么

java:java面试题

PreferenceScreen:PreferenceScreen

getPreference:getPreference

上一篇:塔里木河是内流河还是外流河(塔里木河的起点和终点)
下一篇:华人父母是什么(父亲是中国国籍,母亲是美国国籍,在中国生了小孩 ,是哪个国籍的?)

为您推荐