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


Java PreferenceCategory.addPreference方法代码示例

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


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

示例1: addCheckBox

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private CheckBoxPreference addCheckBox(String title, PreferenceCategory category, String key, Drawable icon, String onText, String offText, boolean defaultValue, Context context) {
    CheckBoxPreference c = new CheckBoxPreference(context);
    c.setTitle(title);
    c.setKey(key);
    if (null != icon) c.setIcon(icon);
    if (offText.equals(null) || onText.equals(null)) {
        if (offText.equals(null)) {
            c.setSummary(onText);
        } else if (onText.equals(null)) {
            c.setSummary(offText);
        }
    } else {
        c.setSummaryOn(onText);
        c.setSummaryOff(offText);
    }
    c.setDefaultValue(defaultValue);
    c.setChecked(KRFAM.sharedPreferences.getBoolean(key, defaultValue));
    category.addPreference(c);
    return c;
}
 
开发者ID:iebb,项目名称:Kasumi,代码行数:21,代码来源:AppPreferences.java

示例2: onCreate

import android.preference.PreferenceCategory; //导入方法依赖的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: onCreate

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

    PreferenceCategory category = new PreferenceCategory(getActivity());
    category.setTitle("Libraries");

    screen.addPreference(category);

    CheckBoxPreference checkBoxPref = new CheckBoxPreference(getActivity());
    checkBoxPref.setTitle("title");
    checkBoxPref.setSummary("summary");
    checkBoxPref.setChecked(true);

    category.addPreference(checkBoxPref);
    setPreferenceScreen(screen);
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:19,代码来源:SettingsActivity.java

示例4: onReceive

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME);
    final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME);
    Log.d(LOG_TAG, "Recieved del application: "+appName+" : "+packageName);
    appManager.delNotificationApp(packageName);
    oPrefs.removeSet(packageName);
    oPrefs.removeString(packageName);
    PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps");
    Preference app = (Preference) findPreference(packageName);
    category.removePreference(app);
    // If no more preference in the category, restore the placeholder
    if(category.getPreferenceCount() <= 0) {
        category.addPreference(preference_apps_placeholder);
    }
    sendNotificationApplications();
}
 
开发者ID:jareddlc,项目名称:OpenFit,代码行数:18,代码来源:OpenFitActivity.java

示例5: updateSelfHostedBlogsPreferenceCategory

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
/**
 * Update the "wpcom blogs" preference category to contain a preference for each blog to configure
 * blog-specific settings.
 */
void updateSelfHostedBlogsPreferenceCategory() {
    PreferenceCategory blogsCategory = (PreferenceCategory) findPreference(getActivity().getString(R.string.pref_key_self_hosted));
    blogsCategory.removeAll();
    int order = 0;

    // Add self-hosted blog button
    Preference addBlogPreference = new Preference(getActivity());
    addBlogPreference.setTitle(R.string.add_self_hosted_blog);
    Intent intentWelcome = new Intent(getActivity(), SignInActivity.class);
    intentWelcome.putExtra(SignInActivity.START_FRAGMENT_KEY, SignInActivity.ADD_SELF_HOSTED_BLOG);
    addBlogPreference.setIntent(intentWelcome);
    addBlogPreference.setOrder(order++);
    blogsCategory.addPreference(addBlogPreference);

    // Add self hosted list
    List<Map<String, Object>> accounts = WordPress.wpDB.getAccountsBy("dotcomFlag=0", null);
    addAccounts(blogsCategory, accounts, order);
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:23,代码来源:SettingsFragment.java

示例6: addAccounts

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void addAccounts(PreferenceCategory category, List<Map<String, Object>> blogs, int order) {
    for (Map<String, Object> account : blogs) {
        String blogName = StringUtils.unescapeHTML(account.get("blogName").toString());
        int accountId = (Integer) account.get("id");

        Preference blogSettingsPreference = new Preference(getActivity());
        blogSettingsPreference.setTitle(blogName);

        try {
            // set blog hostname as preference summary if it differs from the blog name
            URL blogUrl = new URL(account.get("url").toString());
            if (!blogName.equals(blogUrl.getHost())) {
                blogSettingsPreference.setSummary(blogUrl.getHost());
            }
        } catch (MalformedURLException e) {
            // do nothing
        }

        Intent intent = new Intent(getActivity(), BlogPreferencesActivity.class);
        intent.putExtra("id", accountId);
        blogSettingsPreference.setIntent(intent);
        blogSettingsPreference.setOrder(order++);
        category.addPreference(blogSettingsPreference);
    }
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:26,代码来源:SettingsFragment.java

示例7: setupDaydreamPreferences

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void setupDaydreamPreferences() {
    if (!isAdded() ) return;
    enablePreference("autostart",  !Utility.isConfiguredAsDaydream(mContext) );
    Preference pref = findPreference("autostart");
    boolean on = pref.isEnabled();
    String summary = on ? "" : getString(R.string.autostart_message_disabled);
    pref.setSummary(summary);


    PreferenceCategory category = (PreferenceCategory) findPreference("category_behaviour");
    removePreference("force_auto_rotation");
    if (!on) {
        SwitchPreference forceAutoRotation = new SwitchPreference(mContext);
        forceAutoRotation.setKey("force_auto_rotation");
        forceAutoRotation.setTitle(getString(R.string.force_auto_rotation));
        forceAutoRotation.setSummary(getString(R.string.force_auto_rotation_summary));
        forceAutoRotation.setDefaultValue(false);
        category.addPreference(forceAutoRotation);
    }
}
 
开发者ID:firebirdberlin,项目名称:nightdream,代码行数:21,代码来源:PreferencesFragment.java

示例8: addRestoreMorguePreference

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void addRestoreMorguePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, restore it from that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String source = directoryBox.getText().toString();
                    restoreDirectory(source, "/morgue");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.restore_morgue_dialog);
    backupDialogPreference.setDialogTitle(R.string.restore_morgue_directory);
    backupDialogPreference.setTitle(R.string.restore_morgue_directory);
    backupDialogPreference.setPositiveButtonText(R.string.restore);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("morgue");
    saveFilesCategory.addPreference(backupDialogPreference);

}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:27,代码来源:PreferencesActivity.java

示例9: addExportMorguePreference

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void addExportMorguePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, back it up to that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String destination = directoryBox.getText().toString();
                    backupDirectory(destination, "/morgue");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.backup_morgue_dialog);
    backupDialogPreference.setDialogTitle(R.string.backup_morgue_directory);
    backupDialogPreference.setTitle(R.string.backup_morgue_directory);
    backupDialogPreference.setPositiveButtonText(R.string.backup);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("morgue");
    saveFilesCategory.addPreference(backupDialogPreference);
}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:26,代码来源:PreferencesActivity.java

示例10: addPreferenceScreenSensors

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
protected void addPreferenceScreenSensors() {
    ArrayList<DataSource> dataSources = null;
    try {
        dataSources = Configuration.getDataSources();
    } catch (FileNotFoundException e) {
        return;
    }
    String dataSourceType, platformId, dataSourceId, platformType, deviceId;
    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("dataSourceType");
    preferenceCategory.removeAll();
    for (int i = 0; i < dataSources.size(); i++) {
        platformId = dataSources.get(i).getPlatform().getId();
        dataSourceType = dataSources.get(i).getType();
        dataSourceId = dataSources.get(i).getId();
        platformType = dataSources.get(i).getPlatform().getType();
        deviceId = dataSources.get(i).getPlatform().getMetadata().get(METADATA.DEVICE_ID);
        Preference preference = createPreference(dataSourceType, dataSourceId, platformType, platformId, deviceId);
        preferenceCategory.addPreference(preference);
    }
}
 
开发者ID:MD2Korg,项目名称:mCerebrum-AutoSense,代码行数:21,代码来源:PrefsFragmentPlot.java

示例11: addRestoreSavePreference

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void addRestoreSavePreference() {
    DialogPreference backupDialogPreference = new DialogPreference(this,
            null) {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    // Get stuff in edittext, restore it from that directory
                    EditText directoryBox = (EditText) getDialog()
                            .findViewById(R.id.directoryBox);
                    String source = directoryBox.getText().toString();
                    restoreDirectory(source, "/saves");
                    break;
            }
        }
    };
    backupDialogPreference.setDialogLayoutResource(R.layout.restore_saves_dialog);
    backupDialogPreference.setDialogTitle(R.string.restore_save_directory);
    backupDialogPreference.setTitle(R.string.restore_save_directory);
    backupDialogPreference.setPositiveButtonText(R.string.restore);
    backupDialogPreference.setNegativeButtonText(android.R.string.cancel);

    PreferenceCategory saveFilesCategory = (PreferenceCategory) findPreference("saveFiles");
    saveFilesCategory.addPreference(backupDialogPreference);

}
 
开发者ID:michaelbarlow7,项目名称:dungeon-crawl-android,代码行数:27,代码来源:PreferencesActivity.java

示例12: initRingtones

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void initRingtones(PreferenceCategory root) {
    DefaultRingtonePreference phoneRingtonePreference =
            (DefaultRingtonePreference) root.findPreference(KEY_PHONE_RINGTONE);
    if (mPhoneRingtonePreferences != null && !mVoiceCapable || !Utils.isUserOwner()) {
        root.removePreference(phoneRingtonePreference);
        mPhoneRingtonePreferences = null;
    } else {
        mPhoneRingtonePreferences = new ArrayList<DefaultRingtonePreference>();
        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
                Context.TELEPHONY_SERVICE);
        if (telephonyManager.isMultiSimEnabled()){
            root.removePreference(phoneRingtonePreference);
            PreferenceCategory soundCategory = (PreferenceCategory) findPreference(KEY_SOUND);
            for (int i = 0; i < TelephonyManager.getDefault().getSimCount(); i++) {
                DefaultRingtonePreference ringtonePreference =
                        new DefaultRingtonePreference(mContext, null);
                String title = getString(R.string.sim_ringtone_title, i + 1);
                ringtonePreference.setTitle(title);
                ringtonePreference.setSubId(i);
                ringtonePreference.setOrder(0);
                ringtonePreference.setRingtoneType(RingtoneManager.TYPE_RINGTONE);
                soundCategory.addPreference(ringtonePreference);
                mPhoneRingtonePreferences.add(ringtonePreference);
            }
        } else {
            mPhoneRingtonePreferences.add(phoneRingtonePreference);
        }
    }
    mNotificationRingtonePreference = root.findPreference(KEY_NOTIFICATION_RINGTONE);
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:31,代码来源:SoundSettings.java

示例13: initAccounts

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
private void initAccounts() {
	PreferenceCategory accounts = (PreferenceCategory) findPreference(getString(R.string.pref_sipaccounts_key));
	accounts.removeAll();

	// Get already configured extra accounts
	int defaultAccountID = mPrefs.getDefaultAccountIndex();
	int nbAccounts = mPrefs.getAccountCount();
	for (int i = 0; i < nbAccounts; i++) {
		final int accountId = i;
		// For each, add menus to configure it
		String username = mPrefs.getAccountUsername(accountId);
		String domain = mPrefs.getAccountDomain(accountId);
		LedPreference account = new LedPreference(getActivity());

		if (username == null) {
			account.setTitle(getString(R.string.pref_sipaccount));
		} else {
			account.setTitle(username + "@" + domain);
		}

		if (defaultAccountID == i) {
			account.setSummary(R.string.default_account_flag);
		}

		account.setOnPreferenceClickListener(new OnPreferenceClickListener()
		{
			public boolean onPreferenceClick(Preference preference) {
				LinphoneActivity.instance().displayAccountSettings(accountId);
				return false;
			}
		});
		updateAccountLed(account, username, domain, mPrefs.isAccountEnabled(i));
		accounts.addPreference(account);
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:36,代码来源:SettingsFragment.java

示例14: passwordListAvailable

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:33,代码来源:SavePasswordsPreferences.java

示例15: passwordExceptionListAvailable

import android.preference.PreferenceCategory; //导入方法依赖的package包/类
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:28,代码来源:SavePasswordsPreferences.java


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