博客
关于我
android-Creating a Search Interface
阅读量:129 次
发布时间:2019-02-26

本文共 1651 字,大约阅读时间需要 5 分钟。

Android?????????????????????????????????????????Android??????????????????????????????????????

1. ???????

?????????????????????????????????Android 3.0???????????????????????

2. ????????

????????Android 3.0?????????????

  • ????????
  • ??????????
  • ??????????????

3. ??????

?????????????Android??????????????????????????????????

  • android:label??????????
  • android:hint?????????

????????????????

4. ??????

?AndroidManifest.xml???????????????

5. ??????

?SearchableActivity????????????

public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.search);    handleIntent(getIntent());}@Overrideprotected void onNewIntent(Intent intent) {    setIntent(intent);    handleIntent(intent);}private void handleIntent(Intent intent) {    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {        String query = intent.getStringExtra(SearchManager.QUERY);        doMySearch(query);    }}

6. ????????

??????????????Action Bar????????onCreateOptionsMenu????????

@Overridepublic boolean onCreateOptionsMenu(Menu menu) {    // ????    MenuInflater inflater = getMenuInflater();    inflater.inflate(R.menu.options_menu, menu);    // ??????????????    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();    searchView.setSearchableInfo(searchManager.getSearchableInfo());    searchView.setIconifiedByDefault(false); // ?????????    return true;}

????

  • ???????????????????????????????????
  • ????????Action Bar????????????

??????????????Android????????????

转载地址:http://rwdk.baihongyu.com/

你可能感兴趣的文章
PHP删除指定目录下的所有文件和文件夹 | 删除指定文件
查看>>
php删除文件夹下面所有文件包括(删除文件夹)不删除文件夹
查看>>
React Collapse Pane 项目教程
查看>>
php判断ip黑名单程序代码
查看>>
php判断复选框是否被选中的方法
查看>>
PHP判断指定目录下是否存在文件
查看>>
php判断数组是否为空
查看>>
PHP判断数组是否有重复值、获取重复值
查看>>
springboot基于Web的社区留守儿童管理系统源码毕设+论文
查看>>
Springboot基于Redisson实现Redis分布式可重入锁【案例到源码分析】
查看>>
PHP利用正则表达式实现手机号码中间4位用星号(*)替换显示
查看>>
PHP加密与安全的最佳实践
查看>>
PHP区分 企业微信浏览器 | 普通微信浏览器 | 其他浏览器
查看>>
php原生代码怎么连表查询,PHP tp5中使用原生sql查询代码实例
查看>>
PHP去掉转义符
查看>>
php去除字符串开头或末尾的字符(例如逗号)
查看>>
php反射api
查看>>
PHP反射ReflectionClass、ReflectionMethod 入门教程
查看>>
PHP反射机制
查看>>
php取当天的最后一秒_Docker快速搭建PHP开发环境详细教程
查看>>