Android search dialog does not work.

I used this tutorial in the android manual and did everything that was needed even after pressing the search button on the device or in the menu item. it does not open the search dialog. I got a tutorial from here http://developer.android.com/guide/topics/search/search-dialog.html

I have to post my code samples here so that you guys can look into it and help if possible, so I can know where I am going wrong. The activity in which the dialog should be displayed

<activity android:name=".testAndroid" android:theme="@android:style/Theme.NoTitleBar"> <meta-data android:name="android.app.default_searchable" android:value="com.tester.android.Search" /> </activity> 

Activity that returns search results

 <activity android:name=".Search" android:label="Search"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/> </activity> 

my searchable res / xml folder

 <?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="XYZ.com" android:hint="Search XYZ.com" > </searchable> 

Activity showing results

 public class Search extends ListActivity { private Vector<?> loadedArticles; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.articles); Intent intent = getIntent(); String query=""; if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); } boolean articlesLoaded = findArticles(query); // it shows results and renders it. } } 

Can someone help me, please, Why I don’t see the search dialog after clicking the search button.

+4
source share
1 answer

Finally, I myself found a solution to the problem

 <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="XYZ.com" android:hint="Search XYZ.com" > </searchable> 

Here I used lablel and hint as a straight line. Instead, we need to use, @ string / label I mean, our string should be in strings.xml, and then use them. This is a bug in Android.

+12
source

All Articles