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


Java EditTextPreference.setOnPreferenceChangeListener方法代碼示例

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


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

示例1: setValidationListener

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private void setValidationListener(String prefName) {
    EditTextPreference edit_Pref = (EditTextPreference) getPreferenceScreen()
                    .findPreference(prefName);

    edit_Pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // put validation here..
            if (((String) newValue).isEmpty()
                            || InetAddressUtils.isIPv4Address((String) newValue)) {
                return true;
            } else {
                Commons.showMessage("ERROR:\nWrong IP format!", getActivity());
                return false;
            }
        }
    });
}
 
開發者ID:vaginessa,項目名稱:RepWifiApp,代碼行數:20,代碼來源:SettingsActivity.java

示例2: createEditTextPreference

import android.preference.EditTextPreference; //導入方法依賴的package包/類
/**
 * Create an EditTextPreference for the specified preference
 * @param titleResId resource ID to use for the title
 * @param key preference key
 * @return newly created preference
 */
private EditTextPreference createEditTextPreference(@StringRes int titleResId, Settings.Key key) {
    final EditTextPreference editTextPreference = new EditTextPreference(getActivity());
    editTextPreference.setDefaultValue(mSettings.getDefault(key));
    editTextPreference.setKey(key.name());
    editTextPreference.setSummary(mSettings.getString(key));
    editTextPreference.setTitle(titleResId);
    editTextPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            editTextPreference.setSummary((String) newValue);
            return true;
        }
    });
    return editTextPreference;
}
 
開發者ID:nitroshare,項目名稱:nitroshare-android,代碼行數:22,代碼來源:SettingsActivity.java

示例3: onCreate

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

    mLockWipeCategory = (PreferenceCategory) findPreference(KEY_CATEGORY_LOCK_WIPE);
    mMaxTimeScreenLock = (EditTextPreference) findPreference(KEY_MAX_TIME_SCREEN_LOCK);
    mMaxFailures = (EditTextPreference) findPreference(KEY_MAX_FAILS_BEFORE_WIPE);
    mLockScreen = (PreferenceScreen) findPreference(KEY_LOCK_SCREEN);
    mWipeData = (PreferenceScreen) findPreference(KEY_WIPE_DATA);
    mWipeAppData = (PreferenceScreen) findPreference(KEY_WIP_DATA_ALL);

    mMaxTimeScreenLock.setOnPreferenceChangeListener(this);
    mMaxFailures.setOnPreferenceChangeListener(this);
    mLockScreen.setOnPreferenceClickListener(this);
    mWipeData.setOnPreferenceClickListener(this);
    mWipeAppData.setOnPreferenceClickListener(this);
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:19,代碼來源:DeviceAdminSample.java

示例4: onCreate

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    EditTextPreference timerSecondsPref = (EditTextPreference) findPreference("pref_timer_minutes");
    timerSecondsPref
            .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    int value;
                    try {
                        value = Integer.valueOf(newValue.toString());
                    } catch (NumberFormatException nfe) {
                        return false;
                    }
                    return (value > 0 && value < 24 * 60);
                }
            });
}
 
開發者ID:msokolov,項目名稱:DogWord,代碼行數:20,代碼來源:SettingsActivity.java

示例5: initializeNetwork

import android.preference.EditTextPreference; //導入方法依賴的package包/類
protected void initializeNetwork(PreferenceManager manager) {
    mNetworkHostPreference = (EditTextPreference)
                manager.findPreference(getString(R.string.network_host_key));
    mNetworkHostPreference.setOnPreferenceChangeListener(
            mUpdateSummaryListener);

    mNetworkPortPreference = (EditTextPreference)
                manager.findPreference(getString(R.string.network_port_key));
    mNetworkPortPreference.setOnPreferenceChangeListener(
            mUpdateSummaryListener);

    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(this);

    updateSummary(mNetworkHostPreference,
            preferences.getString(getString(
                    R.string.network_host_key), null));

    updateSummary(mNetworkPortPreference,
            preferences.getString(getString(
                    R.string.network_port_key), null));
}
 
開發者ID:bibhrajit,項目名稱:openxc-androidStudio,代碼行數:23,代碼來源:SettingsActivity.java

示例6: addDomainPreferences

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private void addDomainPreferences(PreferenceGroup group) {
    Context context = group.getContext();
    Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
                domain = (String) newValue;
                if (domain.length() == 0) domain = DEFAULT_DOMAIN;
                loadHanabiraCookie();
                return true;
            }
            return false;
        }
    };
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    domainPref.setOnPreferenceChangeListener(updateDomainListener);
    group.addPreference(domainPref);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:26,代碼來源:DobroModule.java

示例7: addKompturcodePreference

import android.preference.EditTextPreference; //導入方法依賴的package包/類
public void addKompturcodePreference(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    EditTextPreference kompturcodePreference = new EditTextPreference(context);
    kompturcodePreference.setTitle(R.string.kraut_prefs_kompturcode);
    kompturcodePreference.setDialogTitle(R.string.kraut_prefs_kompturcode);
    kompturcodePreference.setSummary(R.string.kraut_prefs_kompturcode_summary);
    kompturcodePreference.setKey(getSharedKey(PREF_KEY_KOMPTURCODE_COOKIE));
    kompturcodePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            setKompturcodeCookie((String) newValue);
            return true;
        }
    });
    preferenceGroup.addPreference(kompturcodePreference);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:17,代碼來源:KrautModule.java

示例8: onActivityCreated

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

            // Retrieve the useful instance variables
//            mActivity = (DeviceAdminSample) getActivity();
            mActivity = (DeviceAdminSample) Util.getTargetActivityFormFrag(this);
            mDPM = mActivity.mDPM;
            mDeviceAdminSample = mActivity.mDeviceAdminSample;
            mAdminActive = mActivity.isActiveAdmin();

            // Configure the shared UI elements (if they exist)
            mResetPassword = (EditTextPreference) findPreference(KEY_RESET_PASSWORD);
            mSetPassword = (PreferenceScreen) findPreference(KEY_SET_PASSWORD);

            if (mResetPassword != null) {
                mResetPassword.setOnPreferenceChangeListener(this);
            }
            if (mSetPassword != null) {
                mSetPassword.setOnPreferenceClickListener(this);
            }
        }
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:23,代碼來源:DeviceAdminSample.java

示例9: onActivityCreated

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

    // Retrieve the useful instance variables
    mActivity = (DeviceAdminSample) getActivity();
    mDPM = mActivity.mDPM;
    mDeviceAdminSample = mActivity.mDeviceAdminSample;
    mAdminActive = mActivity.isActiveAdmin();

    // Configure the shared UI elements (if they exist)
    mResetPassword = (EditTextPreference) findPreference(KEY_RESET_PASSWORD);
    mSetPassword = (PreferenceScreen) findPreference(KEY_SET_PASSWORD);

    if (mResetPassword != null) {
        mResetPassword.setOnPreferenceChangeListener(this);
    }
    if (mSetPassword != null) {
        mSetPassword.setOnPreferenceClickListener(this);
    }
}
 
開發者ID:Sherchen,項目名稱:ApiDemos,代碼行數:22,代碼來源:DeviceAdminSample.java

示例10: onCreate

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_date_of_birth);
    setHasOptionsMenu(true);
    EditTextPreference minAgePref = (EditTextPreference) getPreferenceScreen().findPreference(getString(R.string.pref_dob_min_key));
    EditTextPreference maxAgePref = (EditTextPreference) getPreferenceScreen().findPreference(getString(R.string.pref_dob_max_key));
    minAge = Integer.valueOf(minAgePref.getText());
    maxAge = Integer.valueOf(maxAgePref.getText());
    minAgePref.setOnPreferenceChangeListener(this);
    maxAgePref.setOnPreferenceChangeListener(this);
}
 
開發者ID:jthomperoo,項目名稱:Forge,代碼行數:13,代碼來源:DateOfBirthPreferenceFragment.java

示例11: onCreate

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_password);
    setHasOptionsMenu(true);
    EditTextPreference minPassLenPref = (EditTextPreference) getPreferenceScreen().findPreference(getString(R.string.pref_password_min_key));
    EditTextPreference maxPassLenPref = (EditTextPreference) getPreferenceScreen().findPreference(getString(R.string.pref_password_max_key));
    minPassLen = Integer.valueOf(minPassLenPref.getText());
    maxPassLen = Integer.valueOf(maxPassLenPref.getText());
    minPassLenPref.setOnPreferenceChangeListener(this);
    maxPassLenPref.setOnPreferenceChangeListener(this);
}
 
開發者ID:jthomperoo,項目名稱:Forge,代碼行數:13,代碼來源:PasswordPreferenceFragment.java

示例12: loadPreferences

import android.preference.EditTextPreference; //導入方法依賴的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

示例13: onCreate

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

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);

    final Preference infoButton = findPreference("info_button");
    final Preference timetablesButton = findPreference("manage_timetables_button");
    final EditTextPreference syncRangeFuture = (EditTextPreference) findPreference("sync_range_future");
    final EditTextPreference syncRangePast = (EditTextPreference) findPreference("sync_range_past");

    timetablesButton.setOnPreferenceClickListener(preference -> {
        Intent i = new Intent(getActivity(), ManageTimetablesActivity.class);
        startActivity(i);
        getActivity().overridePendingTransition(0, 0);
        return true;
    });

    infoButton.setOnPreferenceClickListener(preference -> {
        InfoDialog.newInstance("About DHBW Timetable", "This app is a project from students of the DHBW Stuttgart.\n\nIt's deployed with\n\nNO WARRANTY\n\nfor correctness or availability.\n\nHendrik Ulbrich, Malte Bartels (c) 2017\n\nhttp://ec.europa.eu/justice/data-protection/article-29/documentation/opinion-recommendation/files/2013/wp202_en.pdf").show(getFragmentManager(), "info");
        return true;
    });

    syncRangeFuture.setSummary(Integer.parseInt(syncRangeFuture.getText()) + " weeks");
    syncRangeFuture.setOnPreferenceChangeListener((preference, newValue) -> {
        syncRangeFuture.setSummary(newValue + " weeks");
        onSyncRangeChange();
        return true;
    });

    syncRangePast.setSummary(Integer.parseInt(syncRangePast.getText()) + " weeks");
    syncRangePast.setOnPreferenceChangeListener((preference, newValue) -> {
        syncRangePast.setSummary(newValue + " weeks");
        onSyncRangeChange();
        return true;
    });

    setHasOptionsMenu(true);
}
 
開發者ID:dhbw-timetable,項目名稱:dhbw-timetable-android,代碼行數:41,代碼來源:PreferencesActivity.java

示例14: onCreate

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    final EditTextPreference username = (EditTextPreference) getPreferenceManager().findPreference("username_preference");

    // Set the title to include the username if there is one
    if( username.getText().length() > 0 )
        username.setTitle("Username (" + username.getText() + ")");

    // This big block of code is equivalent to s/[^A-Za-z0-9_]//g
    InputFilter usernameFilter = new InputFilter() {
        public CharSequence filter(CharSequence source, int start, int end,
                                   Spanned dest, int dstart, int dend) {
            for (int i = start; i < end; i++) {
                if (!Character.isLetterOrDigit(source.charAt(i)) && source.charAt(i) != '_' ) {
                    return "";
                }
            }
            return null;
        }
    };
    username.getEditText().setFilters(new InputFilter[] { usernameFilter });

    // Set a callback so we can update the username text when user changes it
    username.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if( newValue.toString().length() > 0 )
                preference.setTitle("Username (" + newValue.toString() + ")");
            else
                preference.setTitle("Username");
            Log.d("PREFERENCES", "Updated username to: " + newValue.toString());
            return true; // Returning true commits the change
        }
    });

    Log.d("Settings", "Starting settings.");
}
 
開發者ID:DaylightingSociety,項目名稱:WhereAreTheEyes,代碼行數:41,代碼來源:SettingsActivity.java

示例15: onCreate

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

    addPreferencesFromResource(R.xml.preferences);
    editTextPreference = (EditTextPreference) getPreferenceManager().findPreference(Constants.SAVE_PATH);
    editTextPreference.setOnPreferenceChangeListener(this);
    String path = editTextPreference.getSharedPreferences().getString(Constants.SAVE_PATH, "");
    if (!path.equals("musicuu")) {
        editTextPreference.setSummary("當前保存在sd卡下的 " + path + " 文件夾下");
    }
}
 
開發者ID:Qrilee,項目名稱:MusicUU,代碼行數:13,代碼來源:SettingsActivity.java


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