Android Setting 设置项添加到快速搜索

移动开发 waitig 929℃ 百度已收录 0评论

原生Android系统上适配了setting 快速搜索设置项的问题,主要通过一下两点就可以实现:

  1. TestSettings.java
    TestSettings 实现 Indexable
    /**
     * For Search.
     */
    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {

            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();

                SearchIndexableRaw data = new SearchIndexableRaw(context);
                data.title = context.getString(R.string.parallelspace_title111);
                data.screenTitle = context.getString(R.string.parallelspace_title111);
                result.add(data);
                return result;
            }
        };
  1. SearchIndexableResources.java (位于androidsourcecode/android7.0/packages/apps/Settings/src/com/android/settings/search )
     SearchIndexableResources 里添加:
   addIndex(ParallelSpaceSettings.class, NO_DATA_RES_ID,
                R.drawable.ic_settings_notifications);

本文由【waitig】发表在等英博客
本文固定链接:Android Setting 设置项添加到快速搜索
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)