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


Java EditTextPreference.setKey方法代碼示例

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


在下文中一共展示了EditTextPreference.setKey方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
 
開發者ID:nitroshare,項目名稱:nitroshare-android,代碼行數:22,代碼來源:SettingsActivity.java

示例2: 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);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:25,代碼來源:AbstractChanModule.java

示例3: 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

示例4: 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

示例5: 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);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:24,代碼來源:DvachModule.java

示例6: 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);
}
 
開發者ID:PicFrame,項目名稱:picframe,代碼行數:11,代碼來源:OwnCloudPrefs.java

示例7: 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);
}
 
開發者ID:PicFrame,項目名稱:picframe,代碼行數:11,代碼來源:OwnCloudPrefs.java

示例8: 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));
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:40,代碼來源:AbstractChanModule.java

示例9: addPreferencesOnScreen

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    EditTextPreference passwordPref = new EditTextPreference(context);
    passwordPref.setTitle(R.string.iichan_prefs_report_thread);
    passwordPref.setDialogTitle(R.string.iichan_prefs_report_thread);
    passwordPref.setSummary(R.string.iichan_prefs_report_thread_summary);
    passwordPref.setKey(getSharedKey(PREF_KEY_REPORT_THREAD));
    passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    passwordPref.getEditText().setSingleLine();
    passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
    preferenceGroup.addPreference(passwordPref);
    
    super.addPreferencesOnScreen(preferenceGroup);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:16,代碼來源:CirnoModule.java

示例10: addDomainPreference

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private void addDomainPreference(PreferenceGroup group) {
    Context context = group.getContext();
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setDialogTitle(R.string.pref_domain);
    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);
    group.addPreference(domainPref);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:13,代碼來源:NullchanccModule.java

示例11: addDomainPreferences

import android.preference.EditTextPreference; //導入方法依賴的package包/類
/** Добавить категорию настроек домена (в т.ч. https) */
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))) {
                updateDomain((String) newValue, preferences.getBoolean(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA), true));
                return true;
            } else if (preference.getKey().equals(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA))) {
                updateDomain(preferences.getString(getSharedKey(PREF_KEY_DOMAIN), DEFAULT_DOMAIN), (boolean)newValue);
                return true;
            }
            return false;
        }
    };
    PreferenceCategory domainCat = new PreferenceCategory(context);
    domainCat.setTitle(R.string.makaba_prefs_domain_category);
    group.addPreference(domainCat);
    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);
    domainCat.addPreference(domainPref);
    CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать https"
    httpsPref.setTitle(R.string.pref_use_https);
    httpsPref.setSummary(R.string.pref_use_https_summary);
    httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA));
    httpsPref.setDefaultValue(true);
    httpsPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(httpsPref);
}
 
開發者ID:miku-nyan,項目名稱:Overchan-Android,代碼行數:38,代碼來源:MakabaModule.java

示例12: 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);
}
 
開發者ID:PicFrame,項目名稱:picframe,代碼行數:46,代碼來源:OwnCloudPrefs.java

示例13: edit

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private EditTextPreference edit() {
    EditTextPreference pref = new EditTextPreference(a);
    pref.setKey(EDIT);
    return pref;
}
 
開發者ID:pushbit,項目名稱:sprockets-android,代碼行數:6,代碼來源:SprocketsPreferenceFragmentTest.java


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