本文整理汇总了Java中android.preference.EditTextPreference.setDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java EditTextPreference.setDefaultValue方法的具体用法?Java EditTextPreference.setDefaultValue怎么用?Java EditTextPreference.setDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.EditTextPreference
的用法示例。
在下文中一共展示了EditTextPreference.setDefaultValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: updateDateFormatList
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void updateDateFormatList() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Resources res = getResources();
ListPreference dateFormatPref = (ListPreference) findPreference("dateFormat");
String[] dateFormatsValues = res.getStringArray(R.array.dateFormatsValues);
String[] dateFormatsEntries = new String[dateFormatsValues.length];
EditTextPreference customDateFormatPref = (EditTextPreference) findPreference("dateFormatCustom");
customDateFormatPref.setDefaultValue(dateFormatsValues[0]);
SimpleDateFormat sdformat = new SimpleDateFormat();
for (int i=0; i<dateFormatsValues.length; i++) {
String value = dateFormatsValues[i];
if ("custom".equals(value)) {
String renderedCustom;
try {
sdformat.applyPattern(sp.getString("dateFormatCustom", dateFormatsValues[0]));
renderedCustom = sdformat.format(SAMPLE_DATE);
} catch (IllegalArgumentException e) {
renderedCustom = res.getString(R.string.error_dateFormat);
}
dateFormatsEntries[i] = String.format("%s:\n%s",
res.getString(R.string.setting_dateFormatCustom),
renderedCustom);
} else {
sdformat.applyPattern(value);
dateFormatsEntries[i] = sdformat.format(SAMPLE_DATE);
}
}
dateFormatPref.setDefaultValue(dateFormatsValues[0]);
dateFormatPref.setEntries(dateFormatsEntries);
setListPreferenceSummary("dateFormat");
}
示例3: createUsernamePref
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void createUsernamePref() {
EditTextPreference userPref = new EditTextPreference(mSettAct);
userPref.setTitle(mSettAct.getString(R.string.sett_username));
userPref.setSummary(mSettAct.getString(R.string.sett_usernameSumm));
userPref.setKey(mSettAct.getString(R.string.sett_key_username));
userPref.setDefaultValue("");
userPref.getEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
userPref.getEditText().setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS | EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME);
allPrefs.add(userPref);
}
示例4: createPasswordPref
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void createPasswordPref() {
EditTextPreference passordPref = new EditTextPreference(mSettAct);
passordPref.setTitle(mSettAct.getString(R.string.sett_password));
passordPref.setSummary(mSettAct.getString(R.string.sett_passwordSumm));
passordPref.setKey(mSettAct.getString(R.string.sett_key_password));
passordPref.setDefaultValue("");
passordPref.getEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
passordPref.getEditText().setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
allPrefs.add(passordPref);
}
示例5: addProxyPreferences
import android.preference.EditTextPreference; //导入方法依赖的package包/类
/**
* Добавить в группу параметров (на экран/в категорию) новую категорию настроек прокси-сервера
* @param group группа, на которую добавляются параметры
*/
protected void addProxyPreferences(PreferenceGroup group) {
final Context context = group.getContext();
PreferenceCategory proxyCat = new PreferenceCategory(context); //категория настроек прокси
proxyCat.setTitle(R.string.pref_cat_proxy);
group.addPreference(proxyCat);
CheckBoxPreference useProxyPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать ли прокси вообще"
useProxyPref.setTitle(R.string.pref_use_proxy);
useProxyPref.setSummary(R.string.pref_use_proxy_summary);
useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY));
useProxyPref.setDefaultValue(false);
useProxyPref.setOnPreferenceChangeListener(updateHttpListener);
proxyCat.addPreference(useProxyPref);
EditTextPreference proxyHostPref = new LazyPreferences.EditTextPreference(context); //поле ввода адреса прокси-сервера
proxyHostPref.setTitle(R.string.pref_proxy_host);
proxyHostPref.setDialogTitle(R.string.pref_proxy_host);
proxyHostPref.setSummary(R.string.pref_proxy_host_summary);
proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST));
proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST);
proxyHostPref.getEditText().setSingleLine();
proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
proxyHostPref.setOnPreferenceChangeListener(updateHttpListener);
proxyCat.addPreference(proxyHostPref);
proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
EditTextPreference proxyHostPort = new LazyPreferences.EditTextPreference(context); //поле ввода порта прокси-сервера
proxyHostPort.setTitle(R.string.pref_proxy_port);
proxyHostPort.setDialogTitle(R.string.pref_proxy_port);
proxyHostPort.setSummary(R.string.pref_proxy_port_summary);
proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT));
proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT);
proxyHostPort.getEditText().setSingleLine();
proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
proxyHostPort.setOnPreferenceChangeListener(updateHttpListener);
proxyCat.addPreference(proxyHostPort);
proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
}
示例6: createUrlPref
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void createUrlPref() {
EditTextPreference mySrcPathPref = new EditTextPreference(mSettAct);
mySrcPathPref.setTitle(R.string.sett_srcPath_OwnCloud);
mySrcPathPref.setSummary(R.string.sett_srcPath_OwnCloudSumm);
String srcDefault = "https://";
Object obj = SettingsDefaults.getDefaultValueForKey(R.string.sett_key_srcpath_owncloud);
if (obj instanceof String) {
srcDefault = (String) obj;
}
mySrcPathPref.setDefaultValue(srcDefault);
mySrcPathPref.setKey(mSettAct.getString(R.string.sett_key_srcpath_owncloud));
mySrcPathPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (newValue.toString().endsWith(File.separator)) {
Toast
.makeText(
mSettAct,
R.string.sett_toast_wrongUrl,
Toast.LENGTH_SHORT)
.show();
return false;
}
AlertDialog.Builder myDialQBuilder = new AlertDialog.Builder(mSettAct);
myDialQBuilder.setMessage(R.string.sett_dialog_changedURL_message) //
.setNegativeButton(R.string.sett_deleteDataDialog_negBtn, null)
.setPositiveButton(R.string.sett_deleteDataDialog_posBtn,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast
.makeText(mSettAct, R.string.sett_toast_delFiles, Toast.LENGTH_SHORT)
.show();
GlobalPhoneFuncs.recursiveDeletionInBackgroundThread(
new File(AppData.getExtFolderAppRoot()),
false);
}
});
myDialQBuilder.show();
return true;
}
});
mySrcPathPref.getEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
allPrefs.add(mySrcPathPref);
}