The SearchView
and action bar are only available on Android 3.0 and later. To support older platforms, you can fall back to the search dialog. The search dialog is a system provided UI that overlays on top of your application
when invoked.http://blog.csdn.net/sergeycao
Set Minimum and Target API levels
To setup the search dialog, first declare in your manifest that you want to support older devices, but want to target Android 3.0 or later versions. When you do this, your application automatically uses the action bar on Android 3.0 or later and uses the
traditional menu system on older devices:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
<application>
...
Provide the Search Dialog for Older Devices
To invoke the search dialog on older devices, call onSearchRequested()
whenever a user selects the search menu item from the options menu. Because Android 3.0 and higher devices show the
SearchView
in the action bar (as demonstrated in the first lesson), only versions older than 3.0 call
onOptionsItemSelected()
when the user selects the search menu item.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.search:
onSearchRequested();
return true;
default:
return false;
}
}
Check the Android Build Version at Runtime
At runtime, check the device version to make sure an unsupported use of
SearchView
does not occur on older devices. In our example code, this happens in the
onCreateOptionsMenu()
method:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =
(SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
}
return true;
}
分享到:
相关推荐
(Microsoft SQL Server 2005 向后兼容组件) SQL Server Backward Compatibility 包中包含 最新版本的 Data Transformation Services 2000 运行时 (DTS)、SQL 分布式管理对象 (SQL-DMO)、 决策支持对象 (DSO) 和 ...
Microsoft SQL Server 2005 Backward Compatibility Components (Microsoft SQL Server 2005 向后兼容组件) SQL Server Backward Compatibility 包中包含最新版本的 Data Transformation Services 2000 运行时 (DTS...
BACKWARD
包含翻译后的API文档:lucene-backward-codecs-6.6.0-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:6.6.0; 标签:apache、codecs、lucene、backward、jar包...
包含翻译后的API文档:lucene-backward-codecs-7.2.1-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:7.2.1; 标签:apache、lucene、backward、codecs、中英...
1、参考文献:Forward-Backward Error: Automatic Detection of Tracking Failures,文件附带参考文献 2、用matlab、C、Opencv 混合编程实现 3、遇到不兼容时,请在mex文件夹从新编译生成新的“mex”文件
包含翻译后的API文档:lucene-backward-codecs-7.3.1-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:7.3.1; 标签:apache、lucene、backward、codecs、中英...
BP算法的一个简要的demo,前向后向传播函数~
Backward Sky多媒体教室预定系统 Ver20081126 比上个版本有如下更新: 1、修正了源代码没有EXCEL文件夹的BUG 2、图形界面显示模式改为当前一周及下一周 3、图形界面显示多媒体教室超过3个自动换行 4、预定图形界面...
The forward-backward algorithm.pdf
包含翻译后的API文档:lucene-backward-codecs-7.7.0-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:7.7.0; 标签:apache、lucene、backward、codecs、中文文档、jar包...
包含翻译后的API文档:lucene-backward-codecs-7.2.1-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:7.2.1; 标签:apache、lucene、backward、codecs、中文文档、jar包...
包含翻译后的API文档:lucene-backward-codecs-7.3.1-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:7.3.1; 标签:apache、lucene、backward、codecs、中文文档、jar包...
包含翻译后的API文档:lucene-backward-codecs-6.6.0-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:6.6.0; 标签:apache、codecs、lucene、backward、jar包、java、...
包含翻译后的API文档:lucene-backward-codecs-7.7.0-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:org.apache.lucene:lucene-backward-codecs:7.7.0; 标签:apache、lucene、backward、codecs、中英...
向后兼容性ML项目包含两个组件: 一系列损失函数,用户可以在其中分配给失谐因子的权重发生变化,并在机器学习优化过程中探索性能/功能的取舍。 可视化窗口小部件,可帮助用户详细检查指标和错误数据。 它们提供了...
forward sweep and backward sweep load flow
backward forward sweep method for radial distribution system