當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。