當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。