本文整理汇总了Java中android.preference.Preference.setOnPreferenceClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setOnPreferenceClickListener方法的具体用法?Java Preference.setOnPreferenceClickListener怎么用?Java Preference.setOnPreferenceClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setOnPreferenceClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initPreference
import android.preference.Preference; //导入方法依赖的package包/类
/**
* Initializes the Preference based on the state of any policies that may affect it,
* e.g. by showing a managed icon or disabling clicks on the preference.
*
* This should be called once, before the preference is displayed.
*/
public void initPreference(Preference preference) {
if (isPreferenceControlledByPolicy(preference)) {
preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
if (isPreferenceClickDisabledByPolicy(preference)) {
// Disable the views and prevent the Preference from mucking with the enabled state.
preference.setShouldDisableView(false);
// Prevent default click behavior.
preference.setFragment(null);
preference.setIntent(null);
preference.setOnPreferenceClickListener(null);
}
}
}
示例2: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.about_preferences);
Context context = MakiApplication.getContextOfApplication();
PreferenceManager.getDefaultSharedPreferences(context);
//open about dialog
Preference preferenceabout = findPreference("about");
preferenceabout.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder builder =
new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
builder.setTitle(getResources().getString(R.string.about_header));
builder.setMessage(Html.fromHtml(getResources().getString(R.string.about_text)));
builder.setPositiveButton(getResources().getString(R.string.ok), null);
builder.setNegativeButton(null, null);
builder.show();
return true;
}
});
}
示例3: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_theme);
Preference preferencePrimaryColor = findPreference(KEY_PRIMARY_COLOR);
preferencePrimaryColor.setOnPreferenceChangeListener(this);
preferencePrimaryColor.setOnPreferenceClickListener(this);
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
Preference preferenceThemeStyle = findPreference(KEY_THEME_STYLE);
preferenceThemeStyle.setOnPreferenceChangeListener(this);
preferenceThemeStyle.setOnPreferenceClickListener(this);
}
示例4: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
final Preference button = (Preference) findPreference(getString(R.string.pref_rtlSdrPpmInvalidate));
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
useOtherRtlSdrDeviceAreYouSure();
return true;
}
});
}
示例5: setupClearSearchPreference
import android.preference.Preference; //导入方法依赖的package包/类
private void setupClearSearchPreference() {
Preference clearSearchPreference = findPreference(Constants.PREFERENCES_KEY_CLEAR_SEARCH_HISTORY);
if (clearSearchPreference != null) {
clearSearchPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SearchRecentSuggestions suggestions =
new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY,
SearchSuggestionProvider.MODE);
suggestions.clearHistory();
Util.toast(getActivity(), R.string.settings_search_history_cleared);
return false;
}
});
}
}
示例6: initializeIdentitySelection
import android.preference.Preference; //导入方法依赖的package包/类
private void initializeIdentitySelection() {
ContactIdentityManager identity = ContactIdentityManager.getInstance(getActivity());
Preference preference = this.findPreference(TextSecurePreferences.IDENTITY_PREF);
if (identity.isSelfIdentityAutoDetected()) {
this.getPreferenceScreen().removePreference(preference);
} else {
Uri contactUri = identity.getSelfIdentityUri();
if (contactUri != null) {
String contactName = ContactAccessor.getInstance().getNameFromContact(getActivity(), contactUri);
preference.setSummary(String.format(getString(R.string.ApplicationPreferencesActivity_currently_s),
contactName));
}
preference.setOnPreferenceClickListener(new IdentityPreferenceClickListener());
}
}
示例7: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
addPreferencesFromResource(R.xml.settings_main);
// About Version Preference
Preference aboutVersion = findPreference(KEY_ABOUT_VERSION);
aboutVersion.setSummary(AppUtils.getAppVersionName(getActivity()));
aboutVersion.setOnPreferenceClickListener(this);
}
示例8: addSettings_appListener
import android.preference.Preference; //导入方法依赖的package包/类
private void addSettings_appListener() {
Preference reset = findPreference("settings_app");
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference pref) {
helper_main.switchToActivity(getActivity(), Activity_settings_app.class);
return true;
}
});
}
示例9: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Make sure to call this since we're using a different
PreferenceManager prefMgr = getPreferenceManager();
prefMgr.setSharedPreferencesName(SyncToDriveService.PREFERENCES_NAME);
addPreferencesFromResource(R.xml.pref_sync);
setHasOptionsMenu(true);
SetDriveStringDetails();
Preference disconButton = findPreference("clear_drive_data");
if(disconButton != null){
disconButton.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener(){
@Override
public boolean onPreferenceClick(Preference p){
Log.v("SETTING", "Clear Google Login");
ClearDriveID();
// Need to call service
Intent i = new Intent(getActivity(), SyncToDriveService.class).putExtra("clear_drive_data", true);
getActivity().startService(i);
return true;
}
});
}
}
示例10: init_clearreport
import android.preference.Preference; //导入方法依赖的package包/类
private void init_clearreport() {
Preference reset = findPreference("Clear_Report");
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogStyle);
builder.setTitle("Delete all reports?")
.setMessage("Are you sure?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dbHelper.clearReport();
Toast.makeText(context, "Reports removed", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
})
.setNegativeButton("No", null)
.show();
return true;
}
});
}
示例11: addThemeListener
import android.preference.Preference; //导入方法依赖的package包/类
private void addThemeListener() {
Preference reset = findPreference("theme");
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference pref) {
recreate();
return true;
}
});
}
示例12: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle _savedInstanceState) {
super.onCreate(_savedInstanceState);
addPreferencesFromResource(R.xml.pref_settings_help);
mActionBar.setTitle(R.string.settings_information_help_title);
Preference mainList = findPreference("settings_key_main_list");
Preference mainMemoCreate = findPreference("settings_key_main_memocreate");
Preference mainDelete = findPreference("settings_key_main_delete");
Preference mainOpenFolder = findPreference("settings_key_main_openfolder");
Preference folderList = findPreference("settings_key_folder_list");
Preference folderDefault = findPreference("settings_key_folder_default");
Preference folderCreate = findPreference("settings_key_folder_create");
Preference folderDelete = findPreference("settings_key_folder_delete");
Preference folderExternal = findPreference("settings_key_foler_external");
Preference memoSaveLength = findPreference("settings_key_memo_savelengthlimited");
Preference memoFontColor = findPreference("settings_key_memo_fontcolor");
Preference memoEdit = findPreference("settings_key_memo_edit");
Preference etcAboutHelp = findPreference("settings_key_etc_abouthelp");
Preference etcBackup = findPreference("settings_key_etc_backup");
Preference etcFileColor = findPreference("settings_key_etc_filecolor");
Preference etcPermission = findPreference("settings_key_etc_permission");
Preference etcAd = findPreference("settings_key_etc_ad");
Preference etcFontBroken = findPreference("settings_key_etc_fontbroken");
Preference etcWidget = findPreference("settings_key_etc_widget");
Preference.OnPreferenceClickListener clickListener = new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference _preference) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setClass(getActivity(), HelpContentsActivity.class);
intent.putExtra(Constant.INTENT_EXTRA_HELP_INDEX, _preference.getKey());
startActivity(intent);
getActivity().overridePendingTransition(0, 0);
return false;
}
};
mainList.setOnPreferenceClickListener(clickListener);
mainMemoCreate.setOnPreferenceClickListener(clickListener);
mainDelete.setOnPreferenceClickListener(clickListener);
mainOpenFolder.setOnPreferenceClickListener(clickListener);
folderExternal.setOnPreferenceClickListener(clickListener);
folderDelete.setOnPreferenceClickListener(clickListener);
folderCreate.setOnPreferenceClickListener(clickListener);
folderDefault.setOnPreferenceClickListener(clickListener);
folderList.setOnPreferenceClickListener(clickListener);
memoFontColor.setOnPreferenceClickListener(clickListener);
memoSaveLength.setOnPreferenceClickListener(clickListener);
memoEdit.setOnPreferenceClickListener(clickListener);
etcAboutHelp.setOnPreferenceClickListener(clickListener);
etcBackup.setOnPreferenceClickListener(clickListener);
etcFileColor.setOnPreferenceClickListener(clickListener);
etcPermission.setOnPreferenceClickListener(clickListener);
etcAd.setOnPreferenceClickListener(clickListener);
etcFontBroken.setOnPreferenceClickListener(clickListener);
etcWidget.setOnPreferenceClickListener(clickListener);
}
示例13: setConfirmRestore
import android.preference.Preference; //导入方法依赖的package包/类
private void setConfirmRestore() {
Preference pref = getPreferenceScreen().findPreference("pref_restore_default");
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference p) {
Commons.resetSettingsDefault(getActivity(), false);
return true;
}
});
}
示例14: addSettings_searchMainListener
import android.preference.Preference; //导入方法依赖的package包/类
private void addSettings_searchMainListener() {
Preference reset = findPreference("settings_searchMain");
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference pref) {
helper_main.switchToActivity(getActivity(), Activity_settings_searchMain.class);
return true;
}
});
}
示例15: addSettings_dataListener
import android.preference.Preference; //导入方法依赖的package包/类
private void addSettings_dataListener() {
Preference reset = findPreference("settings_data");
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference pref) {
helper_main.switchToActivity(getActivity(), Activity_settings_data.class);
return true;
}
});
}