当前位置: 首页>>代码示例>>Java>>正文


Java EditTextPreference类代码示例

本文整理汇总了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);
}
 
开发者ID:takyonxxx,项目名称:AndroidSdrRtlTuner,代码行数:23,代码来源:SettingsFragment.java

示例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();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:19,代码来源:ServerSettingsFragment.java

示例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 ) );
}
 
开发者ID:NeoSmartpen,项目名称:AndroidSDK2.0,代码行数:18,代码来源:SettingActivity.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:25,代码来源:PreferencesUtil.java

示例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);
	}
}
 
开发者ID:mniip,项目名称:bananapeel,代码行数:20,代码来源:ServerPreferencesScreen.java

示例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));
    }
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:29,代码来源:SettingsActivity.java

示例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;
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:21,代码来源:AttackSettingFragment.java

示例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();
  
}
 
开发者ID:mercuriete,项目名称:android-mrz-reader,代码行数:26,代码来源:PreferencesActivity.java

示例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);
}
 
开发者ID:heipidage,项目名称:GcmForMojo,代码行数:19,代码来源:FragmentPreferences.java

示例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;
            }
        }
    });
}
 
开发者ID:vaginessa,项目名称:RepWifiApp,代码行数:20,代码来源:SettingsActivity.java

示例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();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:26,代码来源:SettingsFragment.java

示例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();
    }
}
 
开发者ID:billthefarmer,项目名称:diary,代码行数:21,代码来源:SettingsFragment.java

示例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));
	
}
 
开发者ID:SoulEaterVTT,项目名称:KotlinStudy,代码行数:19,代码来源:TtsSettings.java

示例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);
				}
			}				
	);		
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:17,代码来源:ReportPreferencesActivity.java

示例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("");
            }
        }
    }
}
 
开发者ID:throwrocks,项目名称:android-udacity-reviews,代码行数:18,代码来源:SettingsActivity.java


注:本文中的android.preference.EditTextPreference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。