当前位置: 首页>>代码示例>>Java>>正文


Java PreferenceGroup.addPreference方法代码示例

本文整理汇总了Java中android.support.v7.preference.PreferenceGroup.addPreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceGroup.addPreference方法的具体用法?Java PreferenceGroup.addPreference怎么用?Java PreferenceGroup.addPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.preference.PreferenceGroup的用法示例。


在下文中一共展示了PreferenceGroup.addPreference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v7.preference.PreferenceGroup; //导入方法依赖的package包/类
@DexAppend
@Override
public void onCreate(Bundle icicle) {
    try {
        PreferenceGroup pg = (PreferenceGroup) findPreference(
                FakeSignatureGlobalUI.DEBUG_APPLICATIONS_CATEGORY_KEY);
        if (pg != null) {
            TwoStatePreference p = createTwoStatePreference(pg.getContext());
            p.setKey(FakeSignatureGlobalUI.SETTING_SECURE_KEY);
            p.setTitle(FakeSignatureGlobalUI.SETTING_TITLE);
            p.setSummary(FakeSignatureGlobalUI.SETTING_SUMMARY);
            p.setPersistent(false);
            mResetTwoStatePrefsAdd(p);
            mAllPrefs.add(p);
            //pg.setOrderingAsAdded(true);
            pg.addPreference(p);
            mAllowFakeSignatureGlobal = p;
        } else {
            Log.e("DevelopmentSettings_FakeSignatureGlobalUI", "cannot find 'applications' preference category");
        }
    } catch (Throwable t) {
        Log.e("DevelopmentSettings_FakeSignatureGlobalUI", "onCreate exception", t);
    }
}
 
开发者ID:Lanchon,项目名称:haystack,代码行数:25,代码来源:DevelopmentSettings.java

示例2: addEditAccountAction

import android.support.v7.preference.PreferenceGroup; //导入方法依赖的package包/类
protected void addEditAccountAction(
        final IGISApplication application,
        final Account account,
        PreferenceGroup actionCategory)
{
    Preference preferenceEdit = new Preference(mStyledContext);
    preferenceEdit.setTitle(R.string.edit_account);
    preferenceEdit.setSummary(R.string.edit_account_summary);

    String url = application.getAccountUrl(account);
    String login = application.getAccountLogin(account);

    Intent intent = new Intent(mStyledContext, NGWLoginActivity.class);
    intent.putExtra(NGWLoginActivity.FOR_NEW_ACCOUNT, false);
    intent.putExtra(NGWLoginActivity.ACCOUNT_URL_TEXT, url);
    intent.putExtra(NGWLoginActivity.ACCOUNT_LOGIN_TEXT, login);
    intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_URL, false);
    intent.putExtra(NGWLoginActivity.CHANGE_ACCOUNT_LOGIN, true);
    preferenceEdit.setIntent(intent);

    actionCategory.addPreference(preferenceEdit);
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:23,代码来源:NGWSettingsFragment.java

示例3: fillAccountPreferences

import android.support.v7.preference.PreferenceGroup; //导入方法依赖的package包/类
public void fillAccountPreferences(
            PreferenceGroup screen,
            final Account account)
    {
        final IGISApplication appContext = (IGISApplication) mStyledContext.getApplicationContext();

        // add sync settings group
        PreferenceCategory syncCategory = new PreferenceCategory(mStyledContext);
        syncCategory.setTitle(R.string.sync);
        screen.addPreference(syncCategory);

        // add auto sync property
        addAutoSyncProperty(appContext, account, syncCategory);

        // add time for periodic sync
        addPeriodicSyncTime(appContext, account, syncCategory);

        // add account layers
        addAccountLayers(screen, appContext, account);

        // add actions group
        PreferenceCategory actionCategory = new PreferenceCategory(mStyledContext);
        actionCategory.setTitle(R.string.actions);
        screen.addPreference(actionCategory);

        // add "Edit account" action
        addEditAccountAction(appContext, account, actionCategory);

        // add delete account action
        addDeleteAccountAction(appContext, account, actionCategory);

// TODO: for isMultiPane() change title of Settings fragment, not of Activity
//        if (mChangeTitle && !NGPreferenceActivity.isMultiPane(mActivity)) {
        if (mChangeTitle) {
            ActionBar ab = mActivity.getSupportActionBar();
            if (null != ab) {
                ab.setTitle(account.name);
            }
        }
    }
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:41,代码来源:NGWSettingsFragment.java

示例4: addAutoSyncProperty

import android.support.v7.preference.PreferenceGroup; //导入方法依赖的package包/类
protected void addAutoSyncProperty(
        final IGISApplication application,
        final Account account,
        PreferenceGroup syncCategory)
{
    final String accountNameHash = "_" + account.name.hashCode();
    SharedPreferences sharedPreferences =
            mStyledContext.getSharedPreferences(Constants.PREFERENCES,
                    Constants.MODE_MULTI_PROCESS);

    CheckBoxPreference enablePeriodicSync = new CheckBoxPreference(mStyledContext);
    enablePeriodicSync.setKey(KEY_SYNC);
    enablePeriodicSync.setPersistent(false);
    enablePeriodicSync.setTitle(R.string.auto_sync);

    boolean isAccountSyncEnabled = isAccountSyncEnabled(account, application.getAuthority());
    enablePeriodicSync.setChecked(isAccountSyncEnabled);
    enablePeriodicSync.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(
                Preference preference,
                Object newValue)
        {
            boolean isChecked = (boolean) newValue;
            setAccountSyncEnabled(account, application.getAuthority(), isChecked);
            return true;
        }
    });

    long timeStamp = sharedPreferences.getLong(
            com.nextgis.maplib.util.SettingsConstants.KEY_PREF_LAST_SYNC_TIMESTAMP
                    + accountNameHash, 0);
    if (isAccountSyncEnabled && timeStamp > 0) {
        enablePeriodicSync.setSummary(ControlHelper.getSyncTime(mStyledContext, timeStamp));
    } else {
        enablePeriodicSync.setSummary(R.string.auto_sync_summary);
    }
    syncCategory.addPreference(enablePeriodicSync);
}
 
开发者ID:nextgis,项目名称:android_maplibui,代码行数:41,代码来源:NGWSettingsFragment.java

示例5: addPreferencesSorted

import android.support.v7.preference.PreferenceGroup; //导入方法依赖的package包/类
private static void addPreferencesSorted(List<Preference> prefs, PreferenceGroup container) {
    // If there's some items to display, sort the items and add them to the container.
    Collections.sort(prefs, new Comparator<Preference>() {
        @Override
        public int compare(Preference lhs, Preference rhs) {
            return lhs.getTitle().toString().toLowerCase().compareTo(rhs.getTitle().toString().toLowerCase());
        }
    });
    for (Preference entry : prefs) {
        container.addPreference(entry);
    }
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:13,代码来源:GcmFragment.java


注:本文中的android.support.v7.preference.PreferenceGroup.addPreference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。