Android EditTextPreference - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android EditTextPreference class.

This code example shows how to use the following methods:getEditText
    preference = new EditTextPreference(context);
  } 
 
  @Test 
  public void testConstructor() { 
    preference = new EditTextPreference(context);
    assertNotNull(preference.getEditText());
  } 
 
  @Test 
  public void testSetText() { 
    preference.setText(SOME_TEXT);
    assertThat((String) preference.getEditText().getText().toString()).isEqualTo(SOME_TEXT);
  } 
 
} 
8
CodeRank
This code example shows how to use the following methods:setText, setSummary
        Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(cr,
                mProviderId, false /* keep updated */, null /* no handler */);
        String text;
 
        text = settings.getXmppResource();
        mXmppResource.setText(text);
        if (text != null) {
            mXmppResource.setSummary(text);
        } 
        text = Integer.toString(settings.getXmppResourcePrio());
        mXmppResourcePrio.setText(text);
        if (text != null) {
            mXmppResourcePrio.setSummary(text);
        } 
        text = Integer.toString(settings.getPort());
        mPort.setText(text);
        if (text != null && text != "5222" && text != "0") {
            mPort.setSummary(text);
        } 
        text = settings.getServer();
7
CodeRank
This code example shows how to use the following methods:getContext, getSharedPreferences, setEnabled, setSummary
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.layout.recentvideo_setting);
	 } 
	 
	@Override 
	public void onResume() { 
		super.onResume(); 
		final EditTextPreference pref = (EditTextPreference)findPreference("recentvideo_last_refresh");
		new RecentVideoRefreshPrefUpdater(pref);
	} 
} 

6
CodeRank
This code example shows how to use the following methods:setText, setDependency, setKey
	 */ 
	@SuppressWarnings("deprecation") 
	protected final EditTextPreference initTextPreference(String baseName, String defValue, String dependency) {
		// Update the loaded Preference with the actual preference key to load/store with 
		EditTextPreference pref = (EditTextPreference) findPreference(baseName);
		pref.setKey(baseName + "_" + key);
		pref.setDependency(dependency == null? null: dependency + "_" + key);
		// Update the Preference by loading the current stored value into the EditText, if it exists 
		pref.setText(sharedPrefs.getString(baseName + "_" + key, defValue));
		return pref;
	} 
 
	/** 
	 * Updates a preference that simply shows a check box. No default value will be shown. 
	 * @param baseName The base name of the stored preference, e.g. item_name, which will then actually be stored under 
	 *            item_name_[key] 
	 * @return The concrete {@link CheckBoxPreference} that is bound to this preference 
	 */ 
	protected final CheckBoxPreference initBooleanPreference(String baseName) {
		return initBooleanPreference(baseName, false);
7
CodeRank
This code example shows how to use the following methods:getEditText, getText, getOnPreferenceChangeListener, setOnPreferenceChangeListener, onPreferenceChange
public class MyPrefScreen extends PreferenceActivity {
	static final LogCategory log = new LogCategory("MyPrefScreen");
	 
	void initNumberEdit(String key,int min,int max,int def,int desc_string_id){
		EditTextPreference pref = (EditTextPreference)findPreference(key);
		EditText et = pref.getEditText();
		et.setHorizontallyScrolling(true);
		et.setSingleLine(true);
		et.setInputType(InputType.TYPE_CLASS_NUMBER);
 
		final int _min = min;
		final int _max = max;
		final int _def = def;
		final int _desc_string_id = desc_string_id;
		 
		pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
			@Override 
			public boolean onPreferenceChange(Preference preference, Object newValue) {
				if(!MyApp.checkInteger(newValue,_min,_max)){
					Toast.makeText(MyPrefScreen.this,R.string.number_range_error,Toast.LENGTH_SHORT).show();

6
CodeRank
This code example shows how to use the following methods:getText
This code example shows how to use the following methods:getContext, getSharedPreferences, setEnabled, setSummary
		this.pref = pref;
		setValues(); 
	} 
 
	private void setValues() { 
		String timeAgoStr = pref.getSharedPreferences().getString("recentvideo_last_refresh", "0");
		String text = "";
		if(timeAgoStr == null || timeAgoStr.length() == 0)  {
			text = "Not yet";
		} 
		else { 
			long timeAgo = Long.valueOf(timeAgoStr);
			text = TimeAgo.toFriendlyString(pref.getContext(), timeAgo);
		} 
		 
		pref.setSummary(text);
		pref.setEnabled(false);
	} 
} 

6
CodeRank
This code example shows how to use the following methods:getText, setSummary
        super.onResume(); 
        updatePreferenceSummaries(); 
    } 
 
    private void updateSummary(EditTextPreference pref, String defaultText) {
        String value = pref.getText();
        if (value != null && value.length() > 0) {
            pref.setSummary(value);
        } else { 
            pref.setSummary(defaultText);
        } 
    } 
        
    private void updatePreferenceSummaries() { 
        updateSummary(urlPref, "URL to garage endpoint");
        updateSummary(ssidPref, "House wifi's SSID to look for");
    } 
 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
6
CodeRank
This code example shows how to use the following methods:setText, setKey, setSummary, setTitle
		thumbnailEnable.setSummaryOff("Миниатюры НЕ отображаются");
		thumbnailEnable.setChecked(true);
 
		prefScreen.addPreference(thumbnailEnable);
 
		homeDir = new EditTextPreference(this);
 
		homeDir.setKey("home_dir");
		homeDir.setTitle("Домашняя папка");
		homeDir.setText(prefScreen.getSharedPreferences().getString("home_dir",
				"/sdcard")); 
		homeDir.setSummary("Эта папка будет отображаться при запуске приложения.Текущая папка "
				+ prefScreen.getSharedPreferences().getString("home_dir",
						"/sdcard")); 
		prefScreen.addPreference(homeDir);
 
	} 
 
	@Override 
	protected void onResume() { 
6
CodeRank
This code example shows how to use the following methods:setSummary

Related Android EditTextPreference Questions & Answers:

See Code Examples for Android EditTextPreference Methods: