0

I want to implement the searchable dictionary demo in my app.I have refereed this example from the Android Samples.

What i have tried so far is ...

I have one layout like below :: enter image description here

Now on click of the Search Image Icon i want to open the enter image description here view like this..

I have implemented like this so far..

AndroidManifest.xml

<activity
            android:name=".home"
            android:screenOrientation="portrait" >

            <!-- Receives the search request. -->
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- Points to searchable meta data. -->
            <meta-data android:name="android.app.searchable" 
                  android:resource="@xml/searchable"/>
        </activity>

Home.java

imgSearch.setOnClickListener(new OnClickListener() 
{
    @Override
    public void onClick(View v) 
    {
        if (intent.getAction().equals(Intent.ACTION_SEARCH))
        {
        
            String query = intent.getStringExtra(SearchManager.QUERY);
            //my SearchLogic 
        {
    }
}

Let me know if i am missing anything...

Any help/suggestions will be appreciated... Thanks in advance...

Community
  • 1
  • 1
AndroidLearner
  • 4,500
  • 4
  • 31
  • 62

1 Answers1

0

Try to implement this way

textMessage.addTextChangedListener(new TextWatcher(){
        public void afterTextChanged(Editable s) {
             String query = intent.getStringExtra(SearchManager.QUERY);
            //my SearchLogic 
            //set listview adapter
        }

    }); 
Hemantvc
  • 2,111
  • 3
  • 30
  • 42
  • so it means i am not able to implement Searchable view on top of my header?? – AndroidLearner Oct 23 '13 at 09:03
  • How? your answer said to implement the TextWatcher but on click of the my Image Search(search icon on top of header) i want to use Searchable Dictionary kind of searching.so can you please explain me bit more to get the clear idea? – AndroidLearner Oct 23 '13 at 09:07
  • ok see following answer http://stackoverflow.com/questions/14118309/how-to-use-search-functionality-in-custom-list-view-in-android/14119383#14119383 2)http://www.androidhive.info/2012/09/android-adding-search-functionality-to-listview/ – Hemantvc Oct 23 '13 at 09:12