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


Java SwitchPreference.setSummary方法代碼示例

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


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

示例1: addSwitchPreferenceBasedOnCheckBoxPreference

import android.preference.SwitchPreference; //導入方法依賴的package包/類
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:18,代碼來源:TwoStatePreferenceHelper.java

示例2: setupDaydreamPreferences

import android.preference.SwitchPreference; //導入方法依賴的package包/類
private void setupDaydreamPreferences() {
    if (!isAdded() ) return;
    enablePreference("autostart",  !Utility.isConfiguredAsDaydream(mContext) );
    Preference pref = findPreference("autostart");
    boolean on = pref.isEnabled();
    String summary = on ? "" : getString(R.string.autostart_message_disabled);
    pref.setSummary(summary);


    PreferenceCategory category = (PreferenceCategory) findPreference("category_behaviour");
    removePreference("force_auto_rotation");
    if (!on) {
        SwitchPreference forceAutoRotation = new SwitchPreference(mContext);
        forceAutoRotation.setKey("force_auto_rotation");
        forceAutoRotation.setTitle(getString(R.string.force_auto_rotation));
        forceAutoRotation.setSummary(getString(R.string.force_auto_rotation_summary));
        forceAutoRotation.setDefaultValue(false);
        category.addPreference(forceAutoRotation);
    }
}
 
開發者ID:firebirdberlin,項目名稱:nightdream,代碼行數:21,代碼來源:PreferencesFragment.java

示例3: updatePreferenceScreen

import android.preference.SwitchPreference; //導入方法依賴的package包/類
void updatePreferenceScreen() {
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("dataSourceType");
    PhoneSensorDataSource phoneSensorDataSource;
    for (int i = 0; i < phoneSensorDataSources.getPhoneSensorDataSources().size(); i++) {
        phoneSensorDataSource = phoneSensorDataSources.getPhoneSensorDataSources().get(i);
        SwitchPreference switchPreference = (SwitchPreference) preferenceCategory.findPreference(phoneSensorDataSource.getDataSourceType());
        switchPreference.setChecked(phoneSensorDataSource.isEnabled());
        if (!isSensorSupported(phoneSensorDataSource.getDataSourceType()))
            switchPreference.setSummary("Not Supported");
        else {
            try {
                switchPreference.setSummary(phoneSensorDataSource.getFrequency() + " Hz");
            } catch (NumberFormatException nfe) {
                switchPreference.setSummary(phoneSensorDataSource.getFrequency());
            }
        }
    }
}
 
開發者ID:MD2Korg,項目名稱:mCerebrum-PhoneSensor,代碼行數:19,代碼來源:PrefsFragmentSettings.java

示例4: updatePreference

import android.preference.SwitchPreference; //導入方法依賴的package包/類
private void updatePreference(int i) {
    AppServiceManager appServiceManager= (AppServiceManager) ModelManager.getInstance(getActivity()).getModel(ModelFactory.MODEL_APP_SERVICE);
    SwitchPreference switchPreference = (SwitchPreference) findPreference(String.valueOf(i));
    Status status = appServiceManager.appServiceList.get(i).getStatus();
    if(status.getStatus()== Status.APP_NOT_INSTALLED) {
        switchPreference.setEnabled(false);
        switchPreference.setChecked(false);
        switchPreference.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_error_red_50dp));
        switchPreference.setSummary(status.getMessage());
    }else if(status.getStatus()== Status.APP_NOT_RUNNING) {
        switchPreference.setEnabled(true);
        switchPreference.setChecked(false);
        switchPreference.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_error_red_50dp));
        switchPreference.setSummary(status.getMessage());
    }else{
        switchPreference.setEnabled(true);
        switchPreference.setChecked(true);
        switchPreference.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_ok_teal_50dp));
        switchPreference.setSummary(status.getMessage());
    }
}
 
開發者ID:MD2Korg,項目名稱:mCerebrum-Study,代碼行數:22,代碼來源:PrefsFragmentServiceApp.java

示例5: setLastBackupTime

import android.preference.SwitchPreference; //導入方法依賴的package包/類
private void setLastBackupTime()
{
    SwitchPreference dailyBackupPref = getDailyBackupPref();

    if( dailyBackupPref != null ) {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        Long lastBackupTime = sharedPreferences.getLong("last_backup_time", 0);

        String lastBackupString = getResources().getString(R.string.last_run)+": ";

        if (lastBackupTime > 0) {
            lastBackupString += DateFormat.getDateTimeInstance().format(lastBackupTime);
        } else {
            lastBackupString += getResources().getString(R.string.never);
        }

        dailyBackupPref.setSummary(lastBackupString);
    }
}
 
開發者ID:bright-tools,項目名稱:androidphotobackup,代碼行數:20,代碼來源:PhotoBackupSettingsActivity.java

示例6: getVibrateDuringDndPreference

import android.preference.SwitchPreference; //導入方法依賴的package包/類
private SwitchPreference getVibrateDuringDndPreference() {
    SwitchPreference vibrateDuringDnd = new SwitchPreference(getActivity());
    vibrateDuringDnd.setKey("pref_key_vibrate_during_dnd");
    vibrateDuringDnd
        .setTitle(getActivity().getString
                  (R.string.vibrate_during_dnd_preference_title));
    vibrateDuringDnd
        .setSummary(getActivity().getString
                  (R.string.vibrate_during_dnd_preference_summary));
    vibrateDuringDnd.setDefaultValue(true);
    return vibrateDuringDnd;
}
 
開發者ID:raatmarien,項目名稱:chibe,代碼行數:13,代碼來源:ChibeFragment.java

示例7: createPreferences

import android.preference.SwitchPreference; //導入方法依賴的package包/類
@SuppressLint("SdCardPath")
/* We hardcode /sdcard/ because we want the user to use /sdcard/ instead of emulated
 * sdcard file paths such as /storage/emulated/0/ that was introduced in Android 4.2
 * due to the multi-user account feature. */
private PreferenceScreen createPreferences(final Context ctx) {
	PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
	prefFontFolder = new Preference(this); 
	prefFontFolder.setTitle(getResources().getString(R.string.font_folder_title));
	prefFontFolder.setKey(Common.KEY_FOLDER_FONT);
	prefFontFolder.setOnPreferenceClickListener(new OnPreferenceClickListener(){
		@Override
		public boolean onPreferenceClick(Preference arg0) {
			Intent i = new Intent(ctx, DirectoryChooserActivity.class);
			i.putExtra(DirectoryChooserActivity.EXTRA_INITIAL_DIRECTORY, "/sdcard/");
			startActivityForResult(i, REQUEST_DIRECTORY);
			return true;
		}
	});
	root.addPreference(prefFontFolder);

	prefFontEverythingEnable = new SwitchPreference(this); 
	prefFontEverythingEnable.setTitle(getResources().getString(R.string.font_everything_enable_title));
	prefFontEverythingEnable.setSummary(getResources().getString(R.string.font_everything_enable_summary));
	prefFontEverythingEnable.setKey(Common.KEY_ENABLE_EVERY_APP);
	root.addPreference(prefFontEverythingEnable);

	updateSummary();
	return root;
}
 
開發者ID:zst123,項目名稱:Xposed-PerAppFonts,代碼行數:30,代碼來源:PrefActivity.java

示例8: initBluetoothPrefs

import android.preference.SwitchPreference; //導入方法依賴的package包/類
private void initBluetoothPrefs() {
    SwitchPreference useBluetoothSwitch = (SwitchPreference) this
            .findPreference(SettingKeys.USE_BLUETOOTH);

    if (bluetoothIsSupported()) {
        useBluetoothSwitch.setEnabled(true);
        initBluetoothDeviceList();
    } else {
        useBluetoothSwitch.setEnabled(false);
        useBluetoothSwitch.setChecked(false);

        String msg = getString(R.string.summary_bluetooth_not_supported);
        useBluetoothSwitch.setSummary(msg);
    }
}
 
開發者ID:jthurne,項目名稱:kanban-salad,代碼行數:16,代碼來源:SettingsActivity.java

示例9: onCreate

import android.preference.SwitchPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {

	super.onCreate(savedInstanceState);
	
	addPreferencesFromResource(R.xml.preferences);
	
	notificationSwitch = 
		(SwitchPreference)findPreference( 
				getString(R.string.notifications_switch_key) );
	notificationSwitch.setTitle(R.string.notifications_switch_title);
	if ( notificationSwitch.isChecked() ) {
		notificationSwitch.setSummary( alarmNextDueString() );
	} else {
		notificationSwitch.setSummary(
				R.string.notifications_switched_off_confirmation);
	}
	notificationSwitch.setOnPreferenceChangeListener(
		new OnPreferenceChangeListener() {
		
			@Override
			public boolean onPreferenceChange(Preference preference, 
												Object newValue) {
				boolean switchValue = (Boolean)newValue;
				Log.d(LOG_TAG, "New value for notification switch will be " 
								+ switchValue);
				if (switchValue == false) {
					Log.d(LOG_TAG, "Disabling notifications... ");
					Alarms.getInstance().cancel();
					SettingsFragment.this.notificationSwitch.setSummary(
						R.string.notifications_switched_off_confirmation);
					showToast(R.string.notifications_switched_off_confirmation);
				} else {
					Log.d(LOG_TAG, "Enabling notifications... ");
					AlarmTimeInterval interval = getAlarmInterval(); 
					Alarms.getInstance().set(interval);
					SettingsFragment.this.notificationSwitch.setSummary( 
						alarmNextDueString() );
					showToast(R.string.notifications_switched_on_confirmation,
								interval.getDays(),
								interval.getHours(),
								interval.getMinutes() );
				}
				
				return true;
			}
		}
	);
	
	preferenceListener = new NextAlarmPreferenceListener();
	getActivity().getSharedPreferences(LOG_TAG, Context.MODE_PRIVATE) 
		.registerOnSharedPreferenceChangeListener(preferenceListener);
}
 
開發者ID:mfitz,項目名稱:android-002,代碼行數:54,代碼來源:SettingsFragment.java

示例10: onCreate

import android.preference.SwitchPreference; //導入方法依賴的package包/類
@Override
public void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	addPreferencesFromResource(R.xml.internal_sensor__confix);

	enabledSensorNr = 0;
	mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

	String[] internalSensorArrayList = getResources().getStringArray(
			R.array.internal_sensor_config);
	for (String s : internalSensorArrayList) {
		final SwitchPreference swp = (SwitchPreference) getPreferenceManager()
				.findPreference(s);
		if (swp.isChecked())
			enabledSensorNr++;

		if (!availableSensor(swp.getKey())) {
			swp.setSummary("not available");
			swp.setEnabled(false);
		} else {
			swp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

				@Override
				public boolean onPreferenceChange(
						Preference preference, Object newValue) {
					if ((Boolean) newValue) {
						if (enabledSensorNr >= 2) {
							openPopupDialog("Warning",
									"More than 2 sensors can't be enabled at once!");
							return false;
						} else {
							enabledSensorNr++;
							return true;
						}
					} else {
						enabledSensorNr--;
						return true;
					}
				}
			});
		}
	}
}
 
開發者ID:myHealthAssistant-tudarmstadt,項目名稱:myHealthHub,代碼行數:44,代碼來源:InternalSensorPreference.java


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