本文整理汇总了Java中android.preference.EditTextPreference.setSummary方法的典型用法代码示例。如果您正苦于以下问题:Java EditTextPreference.setSummary方法的具体用法?Java EditTextPreference.setSummary怎么用?Java EditTextPreference.setSummary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.EditTextPreference
的用法示例。
在下文中一共展示了EditTextPreference.setSummary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例3: 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("");
}
}
}
}
示例4: 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;
}
示例5: updateSummaries
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void updateSummaries() {
EditTextPreference portPref = (EditTextPreference) findPreference("port");
portPref.setSummary(portPref.getText() + " (on " + getIp() + ")");
ListPreference camPref = (ListPreference) findPreference("cam");
camPref.setSummary("Cam " + (Integer.parseInt(camPref.getValue()) + 1));
ListPreference resPref = (ListPreference) findPreference("resolution");
resPref.setSummary(resPref.getValue().replace("x", " x "));
ListPreference rotPref = (ListPreference) findPreference("rotation");
rotPref.setSummary(rotPref.getEntry());
EditTextPreference idPref = (EditTextPreference) findPreference("ssdp_id");
idPref.setSummary(idPref.getText());
EditTextPreference versionPref = (EditTextPreference) findPreference("app_version");
versionPref.setSummary(BuildConfig.VERSION_NAME);
}
示例6: addPreferencesOnScreen
import android.preference.EditTextPreference; //导入方法依赖的package包/类
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
Context context = preferenceGroup.getContext();
addPasswordPreference(preferenceGroup);
CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context);
onionPref.setTitle(R.string.pref_use_onion);
onionPref.setSummary(R.string.pref_use_onion_summary);
onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION));
onionPref.setDefaultValue(false);
onionPref.setDisableDependentsState(true);
preferenceGroup.addPreference(onionPref);
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);
preferenceGroup.addPreference(domainPref);
domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION));
addProxyPreferences(preferenceGroup);
}
示例7: setSummaries
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void setSummaries() {
final EditTextPreference urlPreference = (EditTextPreference) findPreference(PREF_SERVER_URL);
urlPreference.setSummary(preferences.getString(PREF_SERVER_URL, this.getResources().getString(R.string.server_url_summary)));
final String serverPassHash = preferences.getString(PREF_SERVER_PASS_HASH, "");
final EditTextPreference serverPassTextPreference = (EditTextPreference) findPreference(PREF_SERVER_PASS);
if (serverPassHash.isEmpty()) {
serverPassTextPreference.setSummary(getResources().getString(R.string.server_password_summary));
} else {
serverPassTextPreference.setSummary(getResources().getString(R.string.server_password_summary_set));
}
final EditTextPreference httpLoginPreference = (EditTextPreference) findPreference(PREF_SERVER_HTTP_AUTH_LOGIN);
httpLoginPreference.setSummary(preferences.getString(PREF_SERVER_HTTP_AUTH_LOGIN, ""));
final String httpPass = preferences.getString(PREF_SERVER_HTTP_AUTH_PASS,"");
if (!httpPass.isEmpty()) {
final EditTextPreference httpPassPreference = (EditTextPreference) findPreference(PREF_SERVER_HTTP_AUTH_PASS);
httpPassPreference.setSummary(getResources().getString(R.string.server_password_summary_set));
}
}
示例8: createPrefAPIURL
import android.preference.EditTextPreference; //导入方法依赖的package包/类
void createPrefAPIURL() {
EditTextPreference editTextPreference = (EditTextPreference) findPreference("api_url");
if (defaultConfig != null) {
editTextPreference.setEnabled(false);
} else {
editTextPreference.setEnabled(true);
}
if (config.getUrl() == null || config.getUrl().length() == 0)
editTextPreference.setSummary("(not assigned)");
else {
editTextPreference.setSummary(config.getUrl());
}
editTextPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String temp = (String) newValue;
if (temp == null || temp.length() == 0) return false;
config.setUrl(temp);
preference.setSummary(temp);
return false;
}
});
}
示例9: addPasswordPreference
import android.preference.EditTextPreference; //导入方法依赖的package包/类
/**
* Добавить в группу параметров (на экран/в категорию) параметр задания пароля для удаления постов/файлов
* @param group группа, на которую добавляется параметр
*/
protected void addPasswordPreference(PreferenceGroup group) {
final Context context = group.getContext();
EditTextPreference passwordPref = new EditTextPreference(context) {
@Override
protected void showDialog(Bundle state) {
if (createPassword()) {
setText(getDefaultPassword());
}
super.showDialog(state);
}
};
passwordPref.setTitle(R.string.pref_password_title);
passwordPref.setDialogTitle(R.string.pref_password_title);
passwordPref.setSummary(R.string.pref_password_summary);
passwordPref.setKey(getSharedKey(PREF_KEY_PASSWORD));
passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
passwordPref.getEditText().setSingleLine();
passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
group.addPreference(passwordPref);
}
示例10: setPreferenceDefaultValueAndSummary
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void setPreferenceDefaultValueAndSummary(int pref, String value) {
if (value != null) {
EditTextPreference etPref = (EditTextPreference) findPreference(getString(pref));
if (etPref != null) {
etPref.setText(value);
etPref.setSummary(value);
}
}
}
示例11: initNetworkSettings
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void initNetworkSettings() {
((CheckBoxPreference) findPreference(getString(R.string.pref_wifi_only_key))).setChecked(mPrefs.isWifiOnlyEnabled());
// Disable UPnP if ICE si enabled, or disable ICE if UPnP is enabled
CheckBoxPreference ice = (CheckBoxPreference) findPreference(getString(R.string.pref_ice_enable_key));
CheckBoxPreference turn = (CheckBoxPreference) findPreference(getString(R.string.pref_turn_enable_key));
ice.setChecked(mPrefs.isIceEnabled());
turn.setEnabled(mPrefs.getStunServer() != null);
turn.setChecked(mPrefs.isTurnEnabled());
EditTextPreference turnUsername = (EditTextPreference) findPreference(getString(R.string.pref_turn_username_key));
EditTextPreference turnPassword = (EditTextPreference) findPreference(getString(R.string.pref_turn_passwd_key));
turnUsername.setEnabled(mPrefs.isTurnEnabled());
turnUsername.setSummary(mPrefs.getTurnUsername());
turnUsername.setText(mPrefs.getTurnUsername());
turnPassword.setEnabled(mPrefs.isTurnEnabled());
CheckBoxPreference randomPort = (CheckBoxPreference) findPreference(getString(R.string.pref_transport_use_random_ports_key));
randomPort.setChecked(mPrefs.isUsingRandomPort());
// Disable sip port choice if port is random
EditTextPreference sipPort = (EditTextPreference) findPreference(getString(R.string.pref_sip_port_key));
sipPort.setEnabled(!randomPort.isChecked());
sipPort.setSummary(mPrefs.getSipPort());
sipPort.setText(mPrefs.getSipPort());
EditTextPreference stun = (EditTextPreference) findPreference(getString(R.string.pref_stun_server_key));
stun.setSummary(mPrefs.getStunServer());
stun.setText(mPrefs.getStunServer());
((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key))).setChecked(mPrefs.isPushNotificationEnabled());
((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key))).setChecked(mPrefs.isUsingIpv6());
}
示例12: updatePreference
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void updatePreference(Preference preference) {
//Mostra corretamente os objetos
if (preference instanceof ListPreference) {
ListPreference listPreference = (ListPreference) preference;
listPreference.setSummary(listPreference.getEntry());
}
else if(preference instanceof EditTextPreference)
{
EditTextPreference editTextPreference = (EditTextPreference) preference;
editTextPreference.setSummary(editTextPreference.getText());
}
}
示例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: updateSummary
import android.preference.EditTextPreference; //导入方法依赖的package包/类
private void updateSummary(String key) {
switch (key) {
case "httpProxyServer":
case "httpProxyPort":
EditTextPreference editTextPreference = (EditTextPreference) findPreference(key);
if (editTextPreference != null) {
editTextPreference.setSummary(editTextPreference.getText());
}
break;
default:
}
}
示例15: onCreate
import android.preference.EditTextPreference; //导入方法依赖的package包/类
@Override
public final void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
vlcIpAddressPref = (EditTextPreference) findPreference(
Pref.VLC_IP_ADDRESS);
vlcPortPref = (EditTextPreference) findPreference(Pref.VLC_PORT);
// Initialize summaries
SharedPreferences sharedPref = PreferenceManager
.getDefaultSharedPreferences(getActivity());
vlcIpAddressPref.setSummary(sharedPref.getString(
Pref.VLC_IP_ADDRESS, ""));
vlcPortPref.setSummary(sharedPref.getString(Pref.VLC_PORT, ""));
// About
Preference aboutPref = findPreference(Pref.ABOUT);
aboutPref.setOnPreferenceClickListener(
new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(
final Preference preference) {
startActivity(new Intent(getActivity(),
AboutActivity.class));
return false;
}
});
}