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


Java PreferenceFragmentCompat類代碼示例

本文整理匯總了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;
}
 
開發者ID:rohanoid5,項目名稱:Muzesto,代碼行數:24,代碼來源:SpectrumPreferenceCompat.java

示例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;
}
 
開發者ID:google,項目名稱:walt,代碼行數:17,代碼來源:SettingsFragment.java

示例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;
}
 
開發者ID:elbaulp,項目名稱:grado_informatica_npi,代碼行數:19,代碼來源:ClearPatternPreference.java

示例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;
}
 
開發者ID:ChaosLeong,項目名稱:FxcnBeta,代碼行數:24,代碼來源:PreferencesFragment.java

示例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();
}
 
開發者ID:moneymanagerex,項目名稱:android-money-manager-ex,代碼行數:23,代碼來源:BaseSettingsFragmentActivity.java

示例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);
}
 
開發者ID:moneymanagerex,項目名稱:android-money-manager-ex,代碼行數:19,代碼來源:SettingsActivity.java

示例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);
}
 
開發者ID:marunjar,項目名稱:anewjkuapp,代碼行數:23,代碼來源:SettingsFragment.java

示例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();
    }
}
 
開發者ID:TCA-Team,項目名稱:TumCampusApp,代碼行數:27,代碼來源:UserPreferencesActivity.java

示例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());
        }
    }
}
 
開發者ID:gsantner,項目名稱:markor,代碼行數:11,代碼來源:SettingsActivity.java

示例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;
}
 
開發者ID:gsantner,項目名稱:markor,代碼行數:10,代碼來源:GsPreferenceFragmentCompat.java

示例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;
}
 
開發者ID:nextgis,項目名稱:android_nextgis_mobile,代碼行數:13,代碼來源:NGPreferenceActivity.java

示例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);
}
 
開發者ID:nextgis,項目名稱:android_nextgis_mobile,代碼行數:8,代碼來源:NGPreferenceActivity.java

示例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();
}
 
開發者ID:nextgis,項目名稱:android_nextgis_mobile,代碼行數:31,代碼來源:NGPreferenceActivity.java

示例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;
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:15,代碼來源:SettingsActivity.java

示例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));
        }
    }
}
 
開發者ID:gsantner,項目名稱:memetastic,代碼行數:9,代碼來源:GsPreferenceFragmentCompat.java


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