博客
关于我
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/

你可能感兴趣的文章
python之set函数
查看>>
python之virtualenv多环境管理
查看>>
python之web框架(2):了解WSGI接口
查看>>
Python之上下文管理
查看>>
python之元组
查看>>
python之元组
查看>>
Python之列表和元组
查看>>
python之判断一个值是不是可以被调用
查看>>
python之处理excel表格
查看>>
python之字符串【str】
查看>>
Python之并发请求 (干货)
查看>>
python之异常处理
查看>>
python之异常处理
查看>>
Python之杨辉三角算法实现
查看>>
Python之格式化输出讲解
查看>>
python之网络编程1-socket-tcp与udp
查看>>
Python之美[从菜鸟到高手]--Python垃圾回收机制及gc模块详解
查看>>
python之装饰器
查看>>
Python之路,Day18 - 开发一个WEB聊天来撩妹吧
查看>>
python之路--初识函数
查看>>