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


Java PreferenceScreen.getContext方法代码示例

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


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

示例1: 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

示例2: onViewCreated

import android.preference.PreferenceScreen; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final PreferenceScreen preferenceScreen = this.getPreferenceScreen();

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            ProjectService projectService = new ProjectService();
            ArrayList<Project> projects = projectService.getAllProjects();

            //Project temp = new Project();
            //projects.add(temp.setProjectId(5L).setProjectName("foo").setBuildingName("FFUF"));


            PreferenceCategory projectPref = (PreferenceCategory) preferenceScreen.findPreference("pref_key_proj_info");
            ListPreference projectIdList = new ListPreference(preferenceScreen.getContext());
            projectIdList.setKey("project_id_list");
            projectIdList.setTitle("Project");
            projectIdList.setSummary("Select the localization project.");

            // Get project ids and names from projects list.
            String projectNames[] = new String[projects.size()];
            String projectIds[] = new String[projects.size()];
            Log.i(TAG, "Projects:");
            for (int i = 0; i < projects.size(); i++) {
                Log.i(TAG, projects.get(i).getProjectId() + " => " + projects.get(i).getProjectName());
                projectIds[i] = "" + projects.get(i).getProjectId();
                projectNames[i] = projects.get(i).getProjectId() + ": " + projects.get(i).getProjectName() + " (Building: " + projects.get(i).getBuildingName() + ")";
            }

            // Set drop down entries and initialize preferences.
            projectIdList.setEntries(projectNames);
            projectIdList.setEntryValues(projectIds);
            projectIdList.setOnPreferenceChangeListener(new ProjectPreferenceChangeListener(preferenceScreen));
            projectPref.addPreference(projectIdList);
        }
    });
    t.start();
}
 
开发者ID:ProjectIndoor,项目名称:projectindoorapp,代码行数:41,代码来源:SettingsActivity.java


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