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


Java EditTextPreference.setText方法代碼示例

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


在下文中一共展示了EditTextPreference.setText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

示例2: onActivityResult

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent audioReturnedIntent) {
    super.onActivityResult(requestCode, resultCode, audioReturnedIntent);

    if (resultCode == RESULT_OK) {
        Uri selectedAudio = audioReturnedIntent.getData();
        Log.d(TAG, "Announcement selected: " + selectedAudio.toString());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getActivity().grantUriPermission(
                    getActivity().getPackageName(),
                    selectedAudio,
                    Intent.FLAG_GRANT_READ_URI_PERMISSION);
            int takeFlags = audioReturnedIntent.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
            getActivity().getContentResolver().takePersistableUriPermission(selectedAudio, takeFlags);
        }

        EditTextPreference announcementPrefs = (EditTextPreference)findPreference("announcement_file");
        announcementPrefs.setText(selectedAudio.toString());
        announcementPrefs.setSummary(selectedAudio.toString());
    }
}
 
開發者ID:davandev,項目名稱:AlarmController,代碼行數:23,代碼來源:SettingsActivity.java

示例3: setSshPreferencesEnabled

import android.preference.EditTextPreference; //導入方法依賴的package包/類
protected void setSshPreferencesEnabled(boolean enabled) {
	final EditTextPreference portPref = (EditTextPreference) findPreference(PREF_PORT);
	if(enabled) {
		if("10000".equals(portPref.getText())) {
			portPref.setText("22");
			PreferenceHelper.callChangeListener(portPref, portPref.getText());
		}
	} else {
		if("22".equals(portPref.getText())) {
			portPref.setText("10000");
			PreferenceHelper.callChangeListener(portPref, portPref.getText());
		}
	}
	findPreference(PREF_USERNAME).setEnabled(enabled);
	findPreference(PREF_PRIVATE_KEY).setEnabled(enabled);
}
 
開發者ID:sylvain121,項目名稱:Xpra-client-android,代碼行數:17,代碼來源:ConnectionPrefsFragment.java

示例4: bindPreferenceSummaryToValue

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private void bindPreferenceSummaryToValue(Preference preference) {
    String stringValue = PreferenceManager
            .getDefaultSharedPreferences(preference.getContext())
            .getString(preference.getKey(), "");

    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 EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        stringValue = stringValue.replaceFirst("^0+(?!$)", "");

        editTextPreference.setText(stringValue);
        preference.setSummary(stringValue.replaceFirst("^0+(?!$)", ""));
    }
}
 
開發者ID:greenhub-project,項目名稱:batteryhub,代碼行數:25,代碼來源:SettingsActivity.java

示例5: limitIntPrefValue

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private boolean limitIntPrefValue(SharedPreferences sharedPreferences, String key, int minVal, int maxVal, String defaultVal) {
    boolean isValid = true;
    EditTextPreference prefText = (EditTextPreference) getPreferenceScreen().findPreference(key);
    try {
        int newVal = Integer.parseInt(sharedPreferences.getString(key, defaultVal).trim());
        if (newVal > maxVal) {
            sharedPreferences.edit().putString(key, Integer.toString(maxVal)).commit();
            prefText.setText(Integer.toString(maxVal));
            isValid = false;
            Toast.makeText(getApplicationContext(), "Value entered is outside the limits ("+Integer.toString(minVal)+"-"+Integer.toString(maxVal)+"). Reset to "+Integer.toString(maxVal)+".", Toast.LENGTH_LONG).show();
        } else if (newVal < minVal) {
            sharedPreferences.edit().putString(key, Integer.toString(minVal)).commit();
            prefText.setText(Integer.toString(minVal));
            isValid = false;
            Toast.makeText(getApplicationContext(), "Value entered is outside the limits ("+Integer.toString(minVal)+"-"+Integer.toString(maxVal)+"). Reset to "+Integer.toString(minVal)+".", Toast.LENGTH_LONG).show();
        }
    } catch (NumberFormatException e) {
        sharedPreferences.edit().putString(key, defaultVal).commit();
        prefText.setText(defaultVal);
        isValid = false;
        Toast.makeText(getApplicationContext(), "Value entered not numeric ("+Integer.toString(minVal)+"-"+Integer.toString(maxVal)+")! Reset to default.", Toast.LENGTH_LONG).show();
    }
    return isValid;
}
 
開發者ID:JMRI,項目名稱:EngineDriver,代碼行數:26,代碼來源:preferences.java

示例6: setSummary

import android.preference.EditTextPreference; //導入方法依賴的package包/類
/**
 * Set summary for preference
 *
 * @param pref preference
 * @param init true if no recursive
 */
private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
        EditTextPreference editPref = (EditTextPreference) pref;
        pref.setSummary(editPref.getText());

        if (editPref.getKey().equals("logfile") && !init) {
            editPref.setText(PrefStore.getLogFile(this));
            pref.setSummary(editPref.getText());
        }
    }

    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref = (CheckBoxPreference) pref;

        if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
            requestWritePermissions();
        }
    }
}
 
開發者ID:meefik,項目名稱:busybox,代碼行數:31,代碼來源:SettingsActivity.java

示例7: setSummary

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
        EditTextPreference editPref = (EditTextPreference) pref;
        pref.setSummary(editPref.getText());

        if (editPref.getKey().equals("env_dir") && !init) {
            editPref.setText(PrefStore.getEnvDir(this));
            pref.setSummary(editPref.getText());
        }

        if (editPref.getKey().equals("http_conf") &&
                editPref.getText().isEmpty()) {
            editPref.setText(PrefStore.getHttpConf(this));
            pref.setSummary(editPref.getText());
        }
    }

    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref = (CheckBoxPreference) pref;

        if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
            requestWritePermissions();
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:SettingsActivity.java

示例8: 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);
		}
	}
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:10,代碼來源:SettingsFragment.java

示例9: 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());
}
 
開發者ID:treasure-lau,項目名稱:Linphone4Android,代碼行數:34,代碼來源:SettingsFragment.java

示例10: updateFileSourcePrefs

import android.preference.EditTextPreference; //導入方法依賴的package包/類
/**
 * Will try to extract the file source preferences (frequency, sample rate, format) from the filename
 */
public void updateFileSourcePrefs() {
	EditTextPreference etp_filename = 	(EditTextPreference) findPreference(getString(R.string.pref_filesource_file));
	EditTextPreference etp_frequency = 	(EditTextPreference) findPreference(getString(R.string.pref_filesource_frequency));
	EditTextPreference etp_sampleRate = (EditTextPreference) findPreference(getString(R.string.pref_filesource_sampleRate));
	ListPreference lp_format = 			(ListPreference) findPreference(getString(R.string.pref_filesource_format));
	String filename = etp_filename.getText();

	// Format. Search for strings like hackrf, rtl-sdr, ...
	if(filename.matches(".*hackrf.*") || filename.matches(".*HackRF.*") ||
			filename.matches(".*HACKRF.*") || filename.matches(".*hackrfone.*"))
		lp_format.setValue("0");
	if(filename.matches(".*rtlsdr.*") || filename.matches(".*rtl-sdr.*") ||
			filename.matches(".*RTLSDR.*") || filename.matches(".*RTL-SDR.*"))
		lp_format.setValue("1");

	// Sampe Rate. Search for pattern XXXXXXXSps
	if(filename.matches(".*(_|-|\\s)([0-9]+)(sps|Sps|SPS).*"))
		etp_sampleRate.setText(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(sps|Sps|SPS).*", "$2"));
	if(filename.matches(".*(_|-|\\s)([0-9]+)(msps|Msps|MSps|MSPS).*"))
		etp_sampleRate.setText("" + Integer.valueOf(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(msps|Msps|MSps|MSPS).*", "$2")) * 1000000);

	// Frequency. Search for pattern XXXXXXXHz
	if(filename.matches(".*(_|-|\\s)([0-9]+)(hz|Hz|HZ).*"))
		etp_frequency.setText(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(hz|Hz|HZ).*", "$2"));
	if(filename.matches(".*(_|-|\\s)([0-9]+)(mhz|Mhz|MHz|MHZ).*"))
		etp_frequency.setText("" + Integer.valueOf(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(mhz|Mhz|MHz|MHZ).*", "$2")) * 1000000);
}
 
開發者ID:takyonxxx,項目名稱:AndroidSdrRtlTuner,代碼行數:31,代碼來源:SettingsFragment.java

示例11: onViewCreated

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME);
    videoPlayer = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIDEO_PLAYER);
    maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI);
    maxBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE);
    cacheSize = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE);
    cacheLocation = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION);
    preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT);
    bufferLength = (ListPreference) findPreference(Constants.PREFERENCES_KEY_BUFFER_LENGTH);
    incrementTime = (ListPreference) findPreference(Constants.PREFERENCES_KEY_INCREMENT_TIME);
    networkTimeout = (ListPreference) findPreference(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT);
    maxAlbums = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_ALBUMS);
    maxSongs = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_SONGS);
    maxArtists = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_ARTISTS);
    defaultArtists = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_ARTISTS);
    defaultSongs = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SONGS);
    defaultAlbums = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_ALBUMS);
    chatRefreshInterval = (ListPreference) findPreference(Constants.PREFERENCES_KEY_CHAT_REFRESH_INTERVAL);
    directoryCacheTime = (ListPreference) findPreference(Constants.PREFERENCES_KEY_DIRECTORY_CACHE_TIME);
    mediaButtonsEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_MEDIA_BUTTONS);
    lockScreenEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SHOW_LOCK_SCREEN_CONTROLS);
    sendBluetoothAlbumArt = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_ALBUM_ART);
    sendBluetoothNotifications = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SEND_BLUETOOTH_NOTIFICATIONS);
    viewRefresh = (ListPreference) findPreference(Constants.PREFERENCES_KEY_VIEW_REFRESH);
    imageLoaderConcurrency = (ListPreference) findPreference(Constants.PREFERENCES_KEY_IMAGE_LOADER_CONCURRENCY);
    sharingDefaultDescription = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_DESCRIPTION);
    sharingDefaultGreeting = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_GREETING);
    sharingDefaultExpiration = (TimeSpanPreference) findPreference(Constants.PREFERENCES_KEY_DEFAULT_SHARE_EXPIRATION);
    serversCategory = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_SERVERS_KEY);

    sharingDefaultGreeting.setText(Util.getShareGreeting(getActivity()));
    setupClearSearchPreference();
    setupGaplessControlSettingsV14();
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:38,代碼來源:SettingsFragment.java

示例12: setSummary_static

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private static void setSummary_static(AllPrefsFragment allPrefsFragment, String pref_name) {
    try {
        // is there a cleaner way to bind these values when setting programatically?
        final String pref_val = allPrefsFragment.prefs.getString(pref_name, "");
        allPrefsFragment.findPreference(pref_name).setSummary(pref_val);
        EditTextPreference thispref = (EditTextPreference) allPrefsFragment.findPreference(pref_name);
        thispref.setText(pref_val);
    } catch (Exception e) {
        Log.e(TAG, "Exception during setSummary: " + e.toString());
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:12,代碼來源:Preferences.java

示例13: onViewCreated

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setupIconChange();
    PreferenceScreen screen = getPreferenceScreen();
    PreferenceCategory map = (PreferenceCategory) screen.findPreference("pref_cat_map");
    ListPreference type = new ListPreference(this.getActivity());
    if(JappPreferences.useOSM()) {
        type.setKey("pref_map_osm_source");
        type.setTitle(R.string.pref_map_osm_source_title);
        type.setSummary(R.string.pref_map_osm_source_sum);
        type.setEntries(R.array.pref_map_osm_source_options);
        type.setEntryValues(R.array.pref_map_osm_source_options_data);
        type.setDefaultValue(getString(R.string.pref_map_osm_source_options_def));
    } else {
        type.setKey("pref_map_type");
        type.setTitle(R.string.pref_map_type_title);
        type.setSummary(R.string.pref_map_type_sum);
        type.setEntries(R.array.pref_map_type_options);
        type.setEntryValues(R.array.pref_map_type_options_data);
        type.setDefaultValue(getString(R.string.pref_map_type_options_def));
        type.setDialogTitle(R.string.pref_map_type_dialog_title);

        ListPreference style = new ListPreference(this.getActivity());
        style.setKey("pref_map_style");
        style.setTitle(R.string.pref_map_style_title);
        style.setSummary(R.string.pref_map_style_sum);
        style.setEntries(R.array.pref_map_style_options);
        style.setEntryValues(R.array.pref_map_style_options_data);
        style.setDefaultValue(getString(R.string.pref_map_style_options_def));
        style.setDialogTitle(R.string.pref_map_style_dialog_title);
        map.addPreference(style);
    }
    map.addPreference(type);
    EditTextPreference preference = (EditTextPreference)findPreference(JappPreferences.DEBUG_VERSION_NAME);
    preference.setText(getString(R.string.versionName));
}
 
開發者ID:RSDT,項目名稱:Japp16,代碼行數:38,代碼來源:JappPreferenceFragment.java

示例14: onSharedPreferenceChanged

import android.preference.EditTextPreference; //導入方法依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    EditTextPreference portPref = (EditTextPreference) findPreference("port");
    try {
        Integer.parseInt(portPref.getText());
    } catch (NumberFormatException nfe) {
        portPref.setText("8080");
        sharedPreferences.edit().putString("port", "8080").apply();
    }

    populateResolutions();
    updateSummaries();
}
 
開發者ID:arktronic,項目名稱:cameraserve,代碼行數:14,代碼來源:SettingsActivity.java

示例15: populateDiscoverableId

import android.preference.EditTextPreference; //導入方法依賴的package包/類
private void populateDiscoverableId() {
    EditTextPreference idPref = (EditTextPreference) findPreference("ssdp_id");
    String id = idPref.getText();
    if (id == null || id.isEmpty()) {
        id = UUID.randomUUID().toString();
        idPref.setText(id);
    }
}
 
開發者ID:arktronic,項目名稱:cameraserve,代碼行數:9,代碼來源:SettingsActivity.java


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