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

你可能感兴趣的文章
ReentrantLock的公平锁与非公平锁
查看>>
php mysql procedure获取多个结果集
查看>>
php mysql query 行数,PHP和MySQL:返回的行数
查看>>
php mysql session_php使用MySQL保存session会话
查看>>
PHP mysql_real_escape_string() 函数防SQL注入
查看>>
php mysql优化方法_MySQL优化常用方法
查看>>
PHP OAuth 2.0 Server
查看>>
php odbc驱动,php常用ODBC函数集(详细)
查看>>
php openssl aes ecb,php openssl_encrypt AES-128-ECB iOS
查看>>
php paypal rest api,PayPal REST API指定网络配置文件PHP
查看>>
php pcntl 多进程学习
查看>>
PHP pcntl_fork不能在web服务器中使用的变通方法
查看>>
php private ,public protected三者的区别
查看>>
php PSR规范
查看>>