編輯:關於Android編程
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;
}
標注(Marker)是開發者最常使用的地圖覆蓋物志一,今天就來向大家介紹一些標注(Marker)的最基本使用方法! 實現目標: 1、構建基礎地圖頁面; 2、在地圖的中心點
先看一下standard啟動模式的說明:只有一個實例,在同一個應用程序中啟動他的時候,若不存在此Activity實例,則會在當前棧頂創建一個新的實例,若存在,則會把棧中在
關於activity的生命周期:要知道的知識點1.每個生命活動執行的順序、2.每個生命周期我們應該做怎麼樣的處理:每個方法保留的時間有多久;那個方法是活動阻塞的,他沒有做
Android小項目藍牙電子鐘 請支持原創,尊重原創,轉載請注明出處:http://blog.csdn.net/kangweijian(來自kangweijian的c