当前位置: 首页>>代码示例>>Java>>正文


Java ListPreference.setOnPreferenceChangeListener方法代码示例

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


在下文中一共展示了ListPreference.setOnPreferenceChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.custom_prefs);

    // This sample app uses shared preferences to maintain app restriction settings.  Your app
    // can use other methods to maintain the settings.
    mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
    mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
    mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);

    mBooleanPref.setOnPreferenceChangeListener(this);
    mChoicePref.setOnPreferenceChangeListener(this);
    mMultiPref.setOnPreferenceChangeListener(this);

    setRetainInstance(true);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:18,代码来源:CustomRestrictionsFragment.java

示例2: onResume

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onResume() {
    super.onResume();
    ListPreference iconsPack = (ListPreference) findPreference("icons-pack");
    setListPreferenceIconsPacksData(iconsPack, this.getActivity());
    iconsPack.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            getActivity().finish();
            return true;
        }
    });

    IconsHandler iph = GlobState.getIconsHandler(this.getActivity());
    findPreference("icon_tint").setEnabled(iph.isIconTintable(iconsPack.getValue()));

}
 
开发者ID:quaap,项目名称:LaunchTime,代码行数:18,代码来源:SettingsActivity.java

示例3: onCreate

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    final ListPreference list = (ListPreference) findPreference("languageKey");
    list.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            updateLanguage((String)newValue);
            instance.recreate();
            return true;
        }
    });
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:16,代码来源:SpaceRacePreferenceActivity.java

示例4: bindSummary

import android.preference.ListPreference; //导入方法依赖的package包/类
private void bindSummary(String key, final int resId) {
	final ListPreference p = (ListPreference) findPreference(key);
	setPreferenceSummaryValue(p, resId, p.getValue());
	p.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
		@Override
		public boolean onPreferenceChange(Preference preference, Object newValue) {
			setPreferenceSummaryValue(p, resId, (String) newValue);
			return true;
		}
	});
}
 
开发者ID:alescdb,项目名称:LauncherTV,代码行数:12,代码来源:Preferences.java

示例5: loadPreferences

import android.preference.ListPreference; //导入方法依赖的package包/类
private void loadPreferences() {
	addPreferencesFromResource(R.xml.preferences);
	final PreferenceScreen screen = getPreferenceScreen();
	
	mCheckBoxEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_enabled));
	mVibratePart     = (ListPreference)screen.findPreference(getString(R.string.preference_vibrate_parts));
	mTestText        = (EditTextPreference)screen.findPreference(getString(R.string.preference_test));
	mVibrateCounts   = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_counts));
	mDotLength       = (BetterSeekBarPreference)screen.findPreference(getString(R.string.preference_dot_length));
	
	mCheckBoxEnabled.setOnPreferenceChangeListener(mEnabledListener);
	mVibratePart.setOnPreferenceChangeListener(mVibratePartListener);
	//Trigger summary update
	mVibratePartListener.onPreferenceChange(mVibratePart, mVibratePart.getValue());
	mTestText.setOnPreferenceChangeListener(mTestTextListener);
	
	mScreenOffOnly = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_screen_off_only));
	mActiveNormal  = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_normal));
	mActiveVibrate = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_vibrate));
	mActiveSilent  = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_silent));
	
	//mCheckBoxInputEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_input_enabled));
	//mCheckBoxInputEnabled.setOnPreferenceChangeListener(mInputEnabledListener);
	
	final DialogPreference about = (DialogPreference)screen.findPreference(getString(R.string.preference_about));
	about.setDialogLayoutResource(R.layout.about);
	try {
		final String version = getPackageManager().getPackageInfo("com.jakewharton.smsmorse", PackageManager.GET_META_DATA).versionName;
		about.setDialogTitle(getString(R.string.app_name) + " v" + version);
	} catch (Exception e) {}
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:32,代码来源:Preferences.java

示例6: setBackendMethod

import android.preference.ListPreference; //导入方法依赖的package包/类
private void setBackendMethod(final ListPreference listPreference)
{
    listPreference.setPersistent(true);
    listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue)
        {
            int index = listPreference.findIndexOfValue(newValue.toString());
            listPreference.setValueIndex(index != -1 ? index : 0);
            return false;
        }
    });
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:15,代码来源:PreferencesActivity.java

示例7: setAccount

import android.preference.ListPreference; //导入方法依赖的package包/类
private void setAccount(final ListPreference listPreference)
        {
            listPreference.setPersistent(true);
            ArrayList<CharSequence> accnames = ((PreferencesActivity) getActivity()).mAccountNames;

            CharSequence[] names = new CharSequence[accnames.size()];
            names = accnames.toArray(names);

            listPreference.setEntries(names);
            listPreference.setEntryValues(names);

//            String currentSelected = mSharedPrefs.getString("account_selected", "None");
//            int index = listPreference.findIndexOfValue(currentSelected);
//            listPreference.setValueIndex(index != -1 ? index : 0);

            listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
            {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue)
                {
//                    mSharedPrefs.edit().putString("account_selected", newValue.toString()).apply();
                    int index = listPreference.findIndexOfValue(newValue.toString());
                    listPreference.setValueIndex(index != -1 ? index : 0);
                    return false;
                }
            });
        }
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:28,代码来源:PreferencesActivity.java

示例8: onViewCreated

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final PreferenceScreen preferenceScreen = this.getPreferenceScreen();

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            ProjectService projectService = new ProjectService();
            ArrayList<Project> projects = projectService.getAllProjects();

            //Project temp = new Project();
            //projects.add(temp.setProjectId(5L).setProjectName("foo").setBuildingName("FFUF"));


            PreferenceCategory projectPref = (PreferenceCategory) preferenceScreen.findPreference("pref_key_proj_info");
            ListPreference projectIdList = new ListPreference(preferenceScreen.getContext());
            projectIdList.setKey("project_id_list");
            projectIdList.setTitle("Project");
            projectIdList.setSummary("Select the localization project.");

            // Get project ids and names from projects list.
            String projectNames[] = new String[projects.size()];
            String projectIds[] = new String[projects.size()];
            Log.i(TAG, "Projects:");
            for (int i = 0; i < projects.size(); i++) {
                Log.i(TAG, projects.get(i).getProjectId() + " => " + projects.get(i).getProjectName());
                projectIds[i] = "" + projects.get(i).getProjectId();
                projectNames[i] = projects.get(i).getProjectId() + ": " + projects.get(i).getProjectName() + " (Building: " + projects.get(i).getBuildingName() + ")";
            }

            // Set drop down entries and initialize preferences.
            projectIdList.setEntries(projectNames);
            projectIdList.setEntryValues(projectIds);
            projectIdList.setOnPreferenceChangeListener(new ProjectPreferenceChangeListener(preferenceScreen));
            projectPref.addPreference(projectIdList);
        }
    });
    t.start();
}
 
开发者ID:ProjectIndoor,项目名称:projectindoorapp,代码行数:41,代码来源:SettingsActivity.java

示例9: setupUpdatePeriodPreference

import android.preference.ListPreference; //导入方法依赖的package包/类
private void setupUpdatePeriodPreference()
{
  updatePeriodPreference = (ListPreference) findPreference(
    getResources().getString( R.string.prefUpdatePeriodKey )
  );
  updatePeriodPreference.setOnPreferenceChangeListener( listPreferenceListener );
  Android.setListPreferenceSummary(
    updatePeriodPreference, updatePeriodPresenter.getStringValue()
  );
}
 
开发者ID:dr0id3v,项目名称:QuotesOnDesign,代码行数:11,代码来源:PreferenceFragmentGeneral.java

示例10: setupUpdateMethodPreference

import android.preference.ListPreference; //导入方法依赖的package包/类
private void setupUpdateMethodPreference()
{
  updateMethodPreference = (ListPreference) findPreference(
    getResources().getString( R.string.prefUpdateMethodKey )
  );
  updateMethodPreference.setOnPreferenceChangeListener( listPreferenceListener );
  Android.setListPreferenceSummary(
    updateMethodPreference, updateMethodPresenter.getStringValue()
  );
}
 
开发者ID:dr0id3v,项目名称:QuotesOnDesign,代码行数:11,代码来源:PreferenceFragmentGeneral.java

示例11: onCreate

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle onSavedInstanceState) {
    super.onCreate(onSavedInstanceState);
    addPreferencesFromResource(R.xml.settings_appearance);
    mPreferenceManager = this.getPreferenceManager();

    mStartUpScreenPreference = (ListPreference) mPreferenceManager.findPreference("preference_key_startup_screen");
    mStartUpScreenPreference.setOnPreferenceChangeListener((preference, o) -> {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.restart_app);
        builder.setMessage(R.string.restart_app_des);
        builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> {
            dialogInterface.dismiss();
            Intent intent = getActivity().getBaseContext().getPackageManager().getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName());
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            getActivity().finish();
            startActivity(intent);
        });
        builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss());
        builder.create().show();

        return true;
    });


}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:28,代码来源:SettingsAppearanceFragment.java

示例12: onCreateView

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle onSavedInstanceState) {
    mRootView = super.onCreateView(inflater, container, onSavedInstanceState);
    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;
    mListView = (ListView) mRootView.findViewById(android.R.id.list);
    mScanFrequencyPreference=(ListPreference)getPreferenceManager().findPreference("preference_key_scan_frequency");
    mScanFrequencyPreference.setOnPreferenceChangeListener((preference, newValue) -> {
        Logger.log(""+newValue);
        return true;
    });


    mRebuildMusicLibrary = getPreferenceManager().findPreference("preference_key_rebuild_music_library");
    mRebuildMusicLibrary.setOnPreferenceClickListener(preference -> {
        PreferencesHelper.getInstance().put(PreferencesHelper.Key.FIRST_LAUNCH, true);
        //Restart the app.
        Intent i = getActivity().getBaseContext().getPackageManager().getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName());
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        getActivity().finish();
        startActivity(i);
        return false;
    });
    ((SettingActivity) getActivity()).setToolbarTitle(getString(R.string.music_library));

    return mRootView;
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:29,代码来源:SettingsMusicLibraryFragment.java

示例13: prepareListPreference

import android.preference.ListPreference; //导入方法依赖的package包/类
private void prepareListPreference(final ListPreference listPreference)
{
    if (listPreference == null)
    {
        return;
    }

    if (listPreference.getValue() == null)
    {
        // to ensure we don't get a null value
        // set first value by default
        listPreference.setValueIndex(0);
    }

    if (listPreference.getEntry() != null)
    {
        listPreference.setSummary(listPreference.getEntry().toString());
    }
    listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue)
        {
            listPreference.setValue(newValue.toString());
            preference.setSummary(listPreference.getEntry().toString());
            return true;
        }
    });
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:30,代码来源:SettingsActivity.java

示例14: handlePreferenceUi

import android.preference.ListPreference; //导入方法依赖的package包/类
public static void handlePreferenceUi(ListPreference preference) {
    Context context = preference.getContext();
    preference.setValue(getAppliedValue(context));
    preference.setOnPreferenceChangeListener(new PreferenceChangeHandler(context));
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:6,代码来源:IconShapeOverride.java

示例15: setUpListPreference

import android.preference.ListPreference; //导入方法依赖的package包/类
/**
 * Initialize a ListPreference with a certain value.
 * @param preference The ListPreference to initialize.
 * @param value The value to initialize it to.
 */
private void setUpListPreference(Preference preference, ContentSetting value) {
    if (value == null) {
        getPreferenceScreen().removePreference(preference);
        return;
    }

    ListPreference listPreference = (ListPreference) preference;

    int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey());
    CharSequence[] keys = new String[2];
    CharSequence[] descriptions = new String[2];
    keys[0] = ContentSetting.ALLOW.toString();
    keys[1] = ContentSetting.BLOCK.toString();
    descriptions[0] = getResources().getString(
            ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW));
    descriptions[1] = getResources().getString(
            ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK));
    listPreference.setEntryValues(keys);
    listPreference.setEntries(descriptions);
    int index = (value == ContentSetting.ALLOW ? 0 : 1);
    listPreference.setValueIndex(index);
    int explanationResourceId = ContentSettingsResources.getExplanation(contentType);
    if (explanationResourceId != 0) {
        listPreference.setTitle(explanationResourceId);
    }

    if (listPreference.isEnabled()) {
        SiteSettingsCategory category =
                SiteSettingsCategory.fromContentSettingsType(contentType);
        if (category != null && !category.enabledInAndroid(getActivity())) {
            listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity()));
            listPreference.setEnabled(false);
        } else {
            listPreference.setIcon(ContentSettingsResources.getIcon(contentType));
        }
    } else {
        listPreference.setIcon(
                ContentSettingsResources.getDisabledIcon(contentType, getResources()));
    }

    preference.setSummary("%s");
    listPreference.setOnPreferenceChangeListener(this);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:49,代码来源:SingleWebsitePreferences.java


注:本文中的android.preference.ListPreference.setOnPreferenceChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。