本文整理汇总了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;
}
}
});
}
示例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;
}
示例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);
}
示例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);
}
});
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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) {}
}
示例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);
}
示例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.");
}
示例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 + " 文件夹下");
}
}