本文整理汇总了Java中android.support.v7.preference.PreferenceFragmentCompat类的典型用法代码示例。如果您正苦于以下问题:Java PreferenceFragmentCompat类的具体用法?Java PreferenceFragmentCompat怎么用?Java PreferenceFragmentCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PreferenceFragmentCompat类属于android.support.v7.preference包,在下文中一共展示了PreferenceFragmentCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDisplayPreferenceDialog
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
public static boolean onDisplayPreferenceDialog(Preference preference, PreferenceFragmentCompat target) {
boolean handled = false;
if (target.getTargetFragment() instanceof PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback) {
handled = ((PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback) target.getTargetFragment())
.onPreferenceDisplayDialog(target, preference);
}
if (!handled && target.getActivity() instanceof PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback) {
handled = ((PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback) target.getActivity())
.onPreferenceDisplayDialog(target, preference);
}
// check if dialog is already showing
if (!handled && target.getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
handled = true;
}
if (!handled && preference instanceof SpectrumPreferenceCompat) {
DialogFragment f = SpectrumPreferenceDialogFragmentCompat.newInstance(preference.getKey());
f.setTargetFragment(target, 0);
f.show(target.getFragmentManager(), DIALOG_FRAGMENT_TAG);
handled = true;
}
return handled;
}
示例2: onPreferenceStartScreen
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat,
PreferenceScreen preferenceScreen) {
SettingsFragment fragment = new SettingsFragment();
Bundle args = new Bundle();
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
fragment.setArguments(args);
FragmentTransaction ft = preferenceFragmentCompat.getFragmentManager().beginTransaction();
ft.add(R.id.fragment_container, fragment, preferenceScreen.getKey());
ft.addToBackStack(preferenceScreen.getTitle().toString());
ft.commit();
toolbar.setTitle(preferenceScreen.getTitle());
return true;
}
示例3: onDisplayPreferenceDialog
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
public static boolean onDisplayPreferenceDialog(PreferenceFragmentCompat preferenceFragment,
Preference preference) {
if (preference instanceof ClearPatternPreference) {
// getChildFragmentManager() will lead to looking for target fragment in the child
// fragment manager.
FragmentManager fragmentManager = preferenceFragment.getFragmentManager();
if (fragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG) == null) {
ClearPatternPreferenceDialogFragment dialogFragment =
ClearPatternPreferenceDialogFragment.newInstance(preference.getKey());
dialogFragment.setTargetFragment(preferenceFragment, 0);
dialogFragment.show(fragmentManager, DIALOG_FRAGMENT_TAG);
}
return true;
}
return false;
}
示例4: onPreferenceDisplayDialog
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
public boolean onPreferenceDisplayDialog(PreferenceFragmentCompat caller, Preference pref) {
// check if dialog is already showing
if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
return true;
}
if (pref instanceof DialogPreference) {
String key = pref.getKey();
final DialogFragment f;
if (KEY_RELEASE_NOTE.equals(key)) {
f = ReleaseNoteDialogFragment.newInstance(key);
} else if (KEY_LICENSE.equals(key)) {
f = LicenseDialogFragmentProvider.newFragment(getActivity());
} else {
return false;
}
f.setTargetFragment(this, 0);
f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
return true;
}
return false;
}
示例5: setSettingFragment
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
protected void setSettingFragment(PreferenceFragmentCompat fragment) {
// use the class name as the fragment tag.
String tag = fragment.getClass().getSimpleName();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction tx = manager.beginTransaction();
tx.replace(R.id.content, fragment, tag);
// Add to backstack only if this is not the first fragment, and the fragment is not already added.
List<Fragment> fragments = manager.getFragments();
boolean isFirstFragment = fragments == null || fragments.size() == 0;
Fragment existing = manager.findFragmentByTag(tag);
boolean isAdded = existing != null;
if (!isFirstFragment && !isAdded) {
tx.addToBackStack(null);
}
tx.commit();
}
示例6: showFragment
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
private void showFragment() {
// figure out which fragment to show
PreferenceFragmentCompat fragment = null;
Intent intent = getIntent();
String fragmentName = intent.getStringExtra(EXTRA_FRAGMENT);
if (fragmentName != null && fragmentName.equals(PerDatabaseFragment.class.getSimpleName())) {
fragment = new PerDatabaseFragment();
}
// default
if (fragment == null) {
fragment = new SettingsFragment();
}
setSettingFragment(fragment);
}
示例7: onPreferenceTreeClick
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference instanceof PreferenceScreen) {
if (preference.getFragment() != null) {
try {
Class<?> clazz = getActivity().getClassLoader().loadClass(preference.getFragment());
if (PreferenceFragmentCompat.class.isAssignableFrom(clazz)) {
Fragment pf = (Fragment) clazz.getConstructor().newInstance();
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_container, pf, SettingsActivity.ARG_SHOW_FRAGMENT)
.addToBackStack(pf.getClass().getCanonicalName())
.commit();
return true;
}
} catch (Exception e) {
Analytics.sendException(getActivity(), e, false);
}
}
}
return super.onPreferenceTreeClick(preference);
}
示例8: onCreate
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImplicitCounter.count(this);
//Enable the direct access of a specific sub section, e.g.: cards
Intent intent = getIntent();
Bundle args = new Bundle();
if (intent != null && intent.getExtras() != null) {
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, intent.getExtras()
.getString(Const.PREFERENCE_SCREEN));
}
if (savedInstanceState == null) {
// Create the fragment only when the activity is created for the first time. ie. not after orientation changes
Fragment fragment = getSupportFragmentManager().findFragmentByTag(SettingsFragment.FRAGMENT_TAG);
if (fragment == null) {
fragment = new SettingsFragment();
}
fragment.setArguments(args);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.settings_frame, fragment, SettingsFragment.FRAGMENT_TAG);
ft.commit();
}
}
示例9: onPreferenceScreenChanged
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
protected void onPreferenceScreenChanged(PreferenceFragmentCompat preferenceFragmentCompat, PreferenceScreen preferenceScreen) {
super.onPreferenceScreenChanged(preferenceFragmentCompat, preferenceScreen);
if (!TextUtils.isEmpty(preferenceScreen.getTitle())) {
SettingsActivity a = (SettingsActivity) getActivity();
if (a != null) {
a.toolbar.setTitle(preferenceScreen.getTitle());
}
}
}
示例10: onPreferenceStartScreen
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Deprecated
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat preferenceFragmentCompat, PreferenceScreen preferenceScreen) {
_prefScreenBackstack.add(getPreferenceScreen());
preferenceFragmentCompat.setPreferenceScreen(preferenceScreen);
updatePreferenceIcons.callback(this);
onPreferenceScreenChanged(preferenceFragmentCompat, preferenceScreen);
return true;
}
示例11: onPreferenceStartScreen
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
public boolean onPreferenceStartScreen(
PreferenceFragmentCompat preferenceFragmentCompat,
PreferenceScreen preferenceScreen)
{
if (isMultiPane(this)) {
setTitle(preferenceScreen);
}
onStartSubScreen(preferenceScreen);
return true;
}
示例12: onStartSubScreen
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
protected void onStartSubScreen(PreferenceScreen preferenceScreen)
{
Bundle args = new Bundle();
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
args.putString(ConstantsUI.PREF_SCREEN_TITLE, preferenceScreen.getTitle().toString());
replaceSettingsFragment(args);
}
示例13: replaceSettingsFragment
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
public void replaceSettingsFragment(Bundle args)
{
FragmentManager fm = getSupportFragmentManager();
NGPreferenceSettingsFragment fragment = (NGPreferenceSettingsFragment) fm.findFragmentByTag(
getPreferenceSettingsFragmentTag());
if (null != fragment) {
removeListener(fragment);
}
String subScreenKey = null;
if (null != args) {
subScreenKey = args.getString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT);
}
String tag = getPreferenceSettingsFragmentTag();
fragment = getNewPreferenceSettingsFragment(subScreenKey);
addListener(fragment);
if (null != args) {
fragment.setArguments(args);
}
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.setting_fragment, fragment, tag);
if (!isMultiPane(this)) {
ft.addToBackStack(tag);
}
ft.commit();
}
示例14: onPreferenceDisplayDialog
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
@Override
public boolean onPreferenceDisplayDialog(PreferenceFragmentCompat preferenceFragmentCompat, Preference preference) {
final String key = preference.getKey();
DialogFragment f;
if (preference instanceof ColorPreference) {
f = XpColorPreferenceDialogFragment.newInstance(key);
} else {
return false;
}
f.setTargetFragment(preferenceFragmentCompat, 0);
f.show(this.getSupportFragmentManager(), key);
return true;
}
示例15: tintAllPrefIcons
import android.support.v7.preference.PreferenceFragmentCompat; //导入依赖的package包/类
public void tintAllPrefIcons(PreferenceFragmentCompat preferenceFragment, @ColorInt int iconColor) {
for (String prefKey : preferenceFragment.getPreferenceManager().getSharedPreferences().getAll().keySet()) {
Preference pref = preferenceFragment.findPreference(prefKey);
if (pref != null) {
pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
}
}
}