当前位置: 首页>>代码示例>>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;未经允许,请勿转载。