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


Java PreferenceScreen.addPreference方法代码示例

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


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

示例1: onCreate

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_theme);
    final PreferenceScreen screen = getPreferenceScreen();
    final Context context = getActivity();
    final Resources res = getResources();
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        final KeyboardThemePreference pref = new KeyboardThemePreference(
                context, keyboardThemeNames[index], keyboardThemeIds[index]);
        screen.addPreference(pref);
        pref.setOnRadioButtonClickedListener(this);
    }
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    mSelectedThemeId = keyboardTheme.mThemeId;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:19,代码来源:ThemeSettingsFragment.java

示例2: onCreate

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_wireless_socket);
    setHasOptionsMenu(true);

    PreferenceScreen preferenceScreen = this.getPreferenceScreen();

    PreferenceCategory preferenceCategory = new PreferenceCategory(preferenceScreen.getContext());
    preferenceCategory.setTitle("Wireless sockets");
    preferenceScreen.addPreference(preferenceCategory);

    for (int index = 0; index < WirelessSocketService.getInstance().GetDataList().getSize(); index++) {
        WirelessSocket wirelessSocket = WirelessSocketService.getInstance().GetDataList().getValue(index);

        SwitchPreference preference = new SwitchPreference(preferenceScreen.getContext());

        preference.setTitle(wirelessSocket.GetName());
        preference.setKey(wirelessSocket.GetSettingsKey());
        preference.setDefaultValue(false);

        preferenceCategory.addPreference(preference);

        bindPreferenceSummaryToValue(preference);
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:27,代码来源:SettingsActivity.java

示例3: resetList

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
private void resetList() {
    getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.usb_device_preferences);

    PreferenceScreen preferenceScreen = getPreferenceScreen();
    Preference header = preferenceScreen.findPreference(PREF_OBJECT_NAME);
    header.setTitle(mUsbInfo.getName());
    header.setOnPreferenceClickListener(this);

    for (int i = 0; i < mSites.size(); ++i) {
        Website site = mSites.get(i);
        Preference preference = new WebsitePreference(getActivity(), site, mCategory);
        preference.getExtras().putSerializable(SingleWebsitePreferences.EXTRA_SITE, site);
        preference.setFragment(SingleWebsitePreferences.class.getCanonicalName());
        preferenceScreen.addPreference(preference);
    }

    // Force this list to be reloaded if the activity is resumed.
    mSites = null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:UsbDevicePreferences.java

示例4: init

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
/**
 * Initialize internal states of this object.
 *
 * @param context    the context for this application.
 * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
 * @return true if this application is an IME and has two or more subtypes, false otherwise.
 */
public boolean init(final Context context, final PreferenceScreen prefScreen) {
    mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mImi = getMyImi(context, mImm);
    if (mImi == null || mImi.getSubtypeCount() <= 1) {
        return false;
    }
    final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
    intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    mSubtypeEnablerPreference = new Preference(context);
    mSubtypeEnablerPreference.setIntent(intent);
    prefScreen.addPreference(mSubtypeEnablerPreference);
    updateSubtypeEnabler();
    return true;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:25,代码来源:InputMethodSettingsImpl.java

示例5: init

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
/**
 * Initialize internal states of this object.
 * @param context the context for this application.
 * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
 * @return true if this application is an IME and has two or more subtypes, false otherwise.
 */
public boolean init(final Context context, final PreferenceScreen prefScreen) {
    mContext = context;
    mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mImi = getMyImi(context, mImm);
    if (mImi == null || mImi.getSubtypeCount() <= 1) {
        return false;
    }
    mSubtypeEnablerPreference = new Preference(context);
    mSubtypeEnablerPreference
            .setOnPreferenceClickListener(new OnPreferenceClickListener() {
                @Override
                public boolean onPreferenceClick(Preference preference) {
                    final CharSequence title = getSubtypeEnablerTitle(context);
                    final Intent intent =
                            new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
                    intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
                    if (!TextUtils.isEmpty(title)) {
                        intent.putExtra(Intent.EXTRA_TITLE, title);
                    }
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                            | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    context.startActivity(intent);
                    return true;
                }
            });
    prefScreen.addPreference(mSubtypeEnablerPreference);
    updateSubtypeEnabler();
    return true;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:37,代码来源:InputMethodSettingsImpl.java

示例6: addCategory

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
private PreferenceCategory addCategory(String title, PreferenceScreen screen, String key, Drawable icon, Context context) {
    PreferenceCategory c = new PreferenceCategory(context);
    c.setTitle(title);
    if (null != key) c.setKey(key);
    if (null != icon) c.setIcon(icon);
    screen.addPreference(c);
    return c;
}
 
开发者ID:iebb,项目名称:Kasumi,代码行数:9,代码来源:AppPreferences.java

示例7: updateAccountsList

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
private void updateAccountsList() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    if (prefScreen == null) return;

    for (int i = 0; i < mAccountsListPreferences.size(); i++) {
        prefScreen.removePreference(mAccountsListPreferences.get(i));
    }
    mAccountsListPreferences.clear();

    final Preferences activity = (Preferences) getActivity();
    Account[] accounts = AccountManagerHelper.get(activity).getGoogleAccounts();
    int nextPrefOrder = FIRST_ACCOUNT_PREF_ORDER;

    for (Account account : accounts) {
        ChromeBasePreference pref = new ChromeBasePreference(activity);
        pref.setSelectable(false);
        pref.setTitle(account.name);

        boolean isChildAccount = ChildAccountService.isChildAccount();

        pref.setIcon(new BitmapDrawable(getResources(),
                isChildAccount ? getBadgedUserPicture(account.name, getResources()) :
                    getUserPicture(account.name, getResources())));

        pref.setOrder(nextPrefOrder++);
        prefScreen.addPreference(pref);
        mAccountsListPreferences.add(pref);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:30,代码来源:AccountManagementFragment.java

示例8: updateList

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
private void updateList(List<ServiceInfo> services) {
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    Collections.sort(services, new PackageItemInfo.DisplayNameComparator(mPM));
    for (ServiceInfo service : services) {
        final ComponentName cn = new ComponentName(service.packageName, service.name);
        final String title = service.loadLabel(mPM).toString();
        final SwitchPreference pref = new SwitchPreference(mContext);
        pref.setPersistent(false);
        pref.setIcon(service.loadIcon(mPM));
        pref.setTitle(title);
        pref.setChecked(mServiceListing.isEnabled(cn));
        pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                final boolean enable = (boolean) newValue;
                return setEnabled(cn, title, enable);
            }
        });
        screen.addPreference(pref);
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:23,代码来源:ManagedServiceSettings.java

示例9: onCreate

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.prefs);

    PreferenceScreen preferenceScreen = getPreferenceScreen();

    Preference hiddenFolders = findPreference("hiddenFolders");

    SQLiteDatabase hiddenFoldersDB = getActivity().openOrCreateDatabase("HIDDEN", MODE_PRIVATE, null);

    final ArrayList<String> mHiddenFolders = new ArrayList<>();

    Cursor cursor = hiddenFoldersDB.rawQuery("SELECT * FROM foldersList;", null);

    if (cursor != null && cursor.moveToFirst()) {

        while (!cursor.isAfterLast()) {

            mHiddenFolders.add(cursor.getString(cursor.getColumnIndex("folder")));
            cursor.moveToNext();
        }
        cursor.close();
    }


    if (mHiddenFolders.size() != 0) {

        preferenceScreen.addPreference(hiddenFolders);

        hiddenFolders.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {

                HiddenFoldersDialog.show(getActivity(), mHiddenFolders);

                return false;
            }
        });
    } else {
        preferenceScreen.removePreference(hiddenFolders);
    }


    mListenerOptions = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences preftheme, String key) {

            if (key.equals(getResources().getString(R.string.pref_theme)) | key.equals(getResources().getString(R.string.pref_grid))) {

                restartApp(getActivity());
            }
        }
    };


}
 
开发者ID:enricocid,项目名称:Gallery-example,代码行数:59,代码来源:SettingsActivity.java


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