下面列出了android.preference.PreferenceScreen#setIntent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Configure home-as-up for sub-screens.
*/
private void setPreferenceScreenIntent(final PreferenceScreen preferenceScreen)
{
Intent intent = new Intent(getActivity(), CameraSettingsActivity.class);
intent.putExtra(PREF_SCREEN_EXTRA, preferenceScreen.getKey());
preferenceScreen.setIntent(intent);
}
/**
* Sets the default values for the preference screen
*/
private void initPreferences() {
// Binary file location
EditTextPreference binaryFileLocation = (EditTextPreference) findPreference(Constants.PREFERENCE_STORAGE_DIRECTORY);
if (TextUtils.isEmpty(binaryFileLocation.getText())) {
binaryFileLocation.setText(EnvironmentUtil.getProcedureDirectory());
}
// Image downscale factor
EditTextPreference imageDownscale = (EditTextPreference) findPreference(Constants.PREFERENCE_IMAGE_SCALE);
if (TextUtils.isEmpty(imageDownscale.getText())) {
imageDownscale.setText("" + Constants.IMAGE_SCALE_FACTOR);
}
imageDownscale.getEditText().setKeyListener(new DigitsKeyListener());
// View all edu resources
PreferenceScreen resourcePref = (PreferenceScreen) findPreference("s_education_resource");
Intent intent = EducationResourceList.getIntent(Intent.ACTION_PICK,
Audience.ALL);
intent.putExtra(Intent.EXTRA_INTENT, new Intent(Intent.ACTION_VIEW));
resourcePref.setIntent(intent);
// SD card loading procedures
PreferenceScreen intentPref = (PreferenceScreen) findPreference("s_procedures");
intentPref.setIntent(new Intent("org.sana.android.activity.IMPORT_PROCEDURE"));
//intentPref.setIntent(new Intent(ResourceSettings.this,
// ProcedureSdImporter.class));
}
/**
* Sets the default values for the the preferences
*/
private void initPreferences() {
// Health worker username for OpenMRS
EditTextPreference prefEmrUsername = (EditTextPreference) findPreference(Constants.PREFERENCE_EMR_USERNAME);
if (TextUtils.isEmpty(prefEmrUsername.getText())) {
prefEmrUsername.setText(Constants.DEFAULT_USERNAME);
}
// Health worker password for OpenMRS
EditTextPreference prefEmrPassword = (EditTextPreference) findPreference(Constants.PREFERENCE_EMR_PASSWORD);
prefEmrPassword.getEditText().setTransformationMethod(
new PasswordTransformationMethod());
if (TextUtils.isEmpty(prefEmrPassword.getText())) {
prefEmrPassword.setText(Constants.DEFAULT_PASSWORD);
}
// Whether barcode reading is enabled on the phone
/*
* CheckBoxPreference barcodeEnabled = new CheckBoxPreference(this);
* barcodeEnabled.setKey(Constants.PREFERENCE_BARCODE_ENABLED);
* barcodeEnabled.setTitle("Enable barcode reading");
* barcodeEnabled.setSummary
* ("Enable barcode reading of patient and physician ids");
* barcodeEnabled.setDefaultValue(false);
* dialogBasedPrefCat.addPreference(barcodeEnabled);
*/
// Launches network preferences
PreferenceScreen prefNetwork = (PreferenceScreen) findPreference("s_network_settings");
if (prefNetwork != null) {
prefNetwork.setIntent(new Intent(this, NetworkSettings.class));
}
// Launches resource preferences
PreferenceScreen prefResource = (PreferenceScreen) findPreference("s_resource_settings");
if (prefResource != null) {
prefResource.setIntent(new Intent(this, ResourceSettings.class));
}
}