AndroidLearner
AndroidLearner

Reputation: 4636

Unable to implement the searchview like SearchableDictionary Demo

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...

Upvotes: 0

Views: 251

Answers (1)

Hemantvc
Hemantvc

Reputation: 2119

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
        }

    }); 

Upvotes: 0

Related Questions