本文整理汇总了Java中android.preference.EditTextPreference类的典型用法代码示例。如果您正苦于以下问题:Java EditTextPreference类的具体用法?Java EditTextPreference怎么用?Java EditTextPreference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EditTextPreference类属于android.preference包,在下文中一共展示了EditTextPreference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(data != null) {
switch (requestCode) {
case FILESOURCE_RESULT_CODE:
Uri uri = data.getData();
if (uri != null) {
String filepath = FileUtils.getPath(getActivity(), uri);
if(filepath != null) {
((EditTextPreference) findPreference(getString(R.string.pref_filesource_file))).setText(filepath);
updateFileSourcePrefs();
}
else {
Toast.makeText(SettingsFragment.this.getActivity(), "Can't resolve file path from: " + uri.toString(), Toast.LENGTH_LONG).show();
}
}
break;
default:
}
}
super.onActivityResult(requestCode, resultCode, data);
}
示例2: onViewCreated
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
serverNamePref = (EditTextPreference) findPreference(getString(R.string.settings_server_name));
serverUrlPref = (EditTextPreference) findPreference(getString(R.string.settings_server_address));
serverUsernamePref = (EditTextPreference) findPreference(getString(R.string.settings_server_username));
serverPasswordPref = (EditTextPreference) findPreference(getString(R.string.settings_server_password));
equalizerPref = (CheckBoxPreference) findPreference(getString(R.string.equalizer_enabled));
jukeboxPref = (CheckBoxPreference) findPreference(getString(R.string.jukebox_is_default));
removeServerPref = findPreference(getString(R.string.settings_server_remove_server));
testConnectionPref = findPreference(getString(R.string.settings_test_connection_title));
allowSelfSignedCertificatePref = (CheckBoxPreference) findPreference(
getString(R.string.settings_allow_self_signed_certificate));
setupPreferencesValues();
setupPreferencesListeners();
}
示例3: onCreate
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
protected void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
penClient = PenClientCtrl.getInstance( getApplicationContext() );
if(penClient.getProtocolVersion() == 1)
addPreferencesFromResource( R.xml.pref_settings );
else
addPreferencesFromResource( R.xml.pref_settings2 );
mPasswordPref = (EditTextPreference) getPreferenceScreen().findPreference( Const.Setting.KEY_PASSWORD );
EditText myEditText = (EditText) mPasswordPref.getEditText();
myEditText.setKeyListener( DigitsKeyListener.getInstance( false, true ) );
}
示例4: onPreferenceChange
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
} else if (preference instanceof RingtonePreference) {
} else if (preference instanceof EditTextPreference) {
EditTextPreference editTextPreference = (EditTextPreference) preference;
editTextPreference.setSummary(editTextPreference.getText());
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}
示例5: setKeys
import android.preference.EditTextPreference; //导入依赖的package包/类
private void setKeys(PreferenceScreen screen)
{
for(int i = 0; i < screen.getPreferenceCount(); i++)
{
Preference preference = screen.getPreference(i);
String key = server + ";" + preference.getKey();
preference.setKey(key);
if(preference instanceof EditIntPreference)
((EditIntPreference)preference).setInt(preference.getSharedPreferences().getInt(key, -1));
else if(preference instanceof EditTextPreference)
((EditTextPreference)preference).setText(preference.getSharedPreferences().getString(key, null));
else if(preference instanceof ListPreference)
((ListPreference)preference).setValue(preference.getSharedPreferences().getString(key, null));
else if(preference instanceof CheckBoxPreference)
((CheckBoxPreference)preference).setChecked(preference.getSharedPreferences().getBoolean(key, false));
if(preference instanceof PreferenceScreen)
setKeys((PreferenceScreen)preference);
}
}
示例6: bindPreferenceSummaryToValue
import android.preference.EditTextPreference; //导入依赖的package包/类
/**
* Binds a preference's summary to its value. More specifically, when the
* preference's value is changed, its summary (line of text below the
* preference title) is updated to reflect the value. The summary is also
* immediately updated upon calling this method. The exact display format is
* dependent on the type of preference.
*
* @see #sBindPreferenceSummaryToValueListener
*/
private static void bindPreferenceSummaryToValue(Preference preference) {
// Set the listener to watch for value changes.
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
// Trigger the listener immediately with the preference' current value.
if (preference instanceof ListPreference
|| preference instanceof EditTextPreference) {
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
} else if (preference instanceof SwitchPreference
|| preference instanceof CheckBoxPreference) {
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getBoolean(preference.getKey(),true));
}
}
示例7: onPreferenceChange
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(android.preference.Preference preference, Object newValue) {
if (preference instanceof EditTextPreference) {
String value = (String) newValue;
if (TextUtils.isEmpty(value) == false) {
preference.setSummary(value);
} else {
preference.setSummary("없음");
}
}
handler.post(new Runnable() {
@Override
public void run() {
AttackSetting.getInstance().refresh();
}
});
return true;
}
示例8: onCreate
import android.preference.EditTextPreference; //导入依赖的package包/类
/**
* Set the default preference values.
*
* @param savedInstanceState the current Activity's state, as passed by
* Android
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
listPreferenceSourceLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_SOURCE_LANGUAGE_PREFERENCE);
listPreferenceTargetLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_TARGET_LANGUAGE_PREFERENCE);
listPreferenceTranslator = (ListPreference) getPreferenceScreen().findPreference(KEY_TRANSLATOR);
listPreferenceOcrEngineMode = (ListPreference) getPreferenceScreen().findPreference(KEY_OCR_ENGINE_MODE);
editTextPreferenceCharacterBlacklist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_BLACKLIST);
editTextPreferenceCharacterWhitelist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_WHITELIST);
listPreferencePageSegmentationMode = (ListPreference) getPreferenceScreen().findPreference(KEY_PAGE_SEGMENTATION_MODE);
// Create the entries/entryvalues for the translation target language list.
initTranslationTargetList();
}
示例9: PrefListener
import android.preference.EditTextPreference; //导入依赖的package包/类
public PrefListener(String key) {
super();
Preference preference = findPreference(key);
format = preference.getSummary().toString();
if (EditTextPreference.class.isInstance(preference)) {
// EditText
EditTextPreference etp = (EditTextPreference) preference;
onPreferenceChange(preference, etp.getText());
} else if (ListPreference.class.isInstance(preference)) {
// List 切换推送通道 注册及关闭Miui和华为推送
ListPreference lp = (ListPreference) preference;
onPreferenceChange(preference, lp.getEntry());
} else {
Log.e("GcmForMojoSetting", "不支持的Preference类型");
}
preference.setOnPreferenceChangeListener(this);
}
示例10: 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;
}
}
});
}
示例11: onCreate
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_settings);
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
btcPrecisionPreference = findPreference(Configuration.PREFS_KEY_BTC_PRECISION);
btcPrecisionPreference.setOnPreferenceChangeListener(this);
trustedPeerPreference = findPreference(Configuration.PREFS_KEY_TRUSTED_PEER);
((EditTextPreference) trustedPeerPreference).getEditText().setSingleLine();
trustedPeerPreference.setOnPreferenceChangeListener(this);
trustedPeerOnlyPreference = findPreference(Configuration.PREFS_KEY_TRUSTED_PEER_ONLY);
trustedPeerOnlyPreference.setOnPreferenceChangeListener(this);
final Preference dataUsagePreference = findPreference(Configuration.PREFS_KEY_DATA_USAGE);
dataUsagePreference.setEnabled(pm.resolveActivity(dataUsagePreference.getIntent(), 0) != null);
updateTrustedPeer();
}
示例12: onSharedPreferenceChanged
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences,
String key)
{
if (key.equals(Diary.PREF_FOLDER))
{
// Get folder summary
EditTextPreference folder =
(EditTextPreference) findPreference(key);
// Set folder in text view
folder.setSummary(preferences.getString(key, Diary.DIARY));
}
if (key.equals(Diary.PREF_DARK_THEME))
{
if (Build.VERSION.SDK_INT != VERSION_M)
getActivity().recreate();
}
}
示例13: onCreate
import android.preference.EditTextPreference; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
// 指定保存文件名字
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
addPreferencesFromResource(R.xml.tts_setting);
mSpeedPreference = (EditTextPreference)findPreference("speed_preference");
mSpeedPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mSpeedPreference,0,200));
mPitchPreference = (EditTextPreference)findPreference("pitch_preference");
mPitchPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mPitchPreference,0,100));
mVolumePreference = (EditTextPreference)findPreference("volume_preference");
mVolumePreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mVolumePreference,0,100));
}
示例14: onCreate
import android.preference.EditTextPreference; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.report_preferences);
getCurrenciesList();
final EditTextPreference pReportReferenceCurrency = (EditTextPreference)getPreferenceScreen().findPreference("report_reference_currency");
pReportReferenceCurrency.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
return showChoiceList(pReportReferenceCurrency);
}
}
);
}
示例15: updatePreference
import android.preference.EditTextPreference; //导入依赖的package包/类
private void updatePreference(String key, String newValue){
if (key.equals(API_KEY)){
Preference preference = findPreference(key);
if (preference instanceof EditTextPreference){
EditTextPreference editTextPreference = (EditTextPreference) preference;
PreferencesHelper preferencesHelper = new PreferencesHelper(getApplicationContext());
preferencesHelper.save(API_KEY, newValue);
if (newValue != null ){
editTextPreference.setText(newValue);
editTextPreference.setSummary(newValue);
}else{
editTextPreference.setText("");
editTextPreference.setSummary("");
}
}
}
}