I am trying to implement a search in my Android application using the search bar widget in the action bar.
I follow
http://developer.android.com/guide/topics/search/search-dialog.html http://developer.android.com/guide/topics/ui/actionbar.html#ActionView
to do this.
I have two actions related to the search. SearchBar activity has an action bar, and AcceptSearch is my searchable activity. Despite the fact that I announced which action is a search activity, the request is not sent to AcceptSearch, and the action does not start.
I have configured the search bar so that the search bar hint appears when the widget is empty, but the hint never appears. Here is my code.
SearchBar
public class SearchBar extends Activity { @Override protected void onCreate(Bundle savedInstanceState) {
AcceptSearch
public class AcceptSearch extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash_screen);
Searchable.xml
<?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/app_label" android:hint="@string/search_hint"> </searchable>
options_menu
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:title="Help" android:id="@+id/menu_help" android:showAsAction="always" /> <item android:title="Categories" android:id="@+id/menu_cats" android:showAsAction="always" /> <item android:id="@+id/menu_search" android:title="Search with Searchlet" android:icon="@drawable/ic_action_search" android:showAsAction="ifRoom|collapseActionView" android:actionViewClass="android.widget.SearchView"/> </menu>
manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.searchlet" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".SplashScreenActivity" android:label="@string/title_activity_splash_screen" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".AcceptSearch"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/> </activity> <activity android:name=".SearchBar" android:label="@string/app_name"> <intent-filter> <action android:name="com.example.searchlet.CLEARSCREEN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest>
I believe that all the necessary information recreates the situation.
Thanks to everyone in advance. I understand.
java android android-manifest
myselfesteem
source share