Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3667952
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:03:51+00:00 2026-05-19T02:03:51+00:00

Hi im trying to use a searchable activity in my application but when the

  • 0

Hi im trying to use a searchable activity in my application but when the search button is pressed nothing happens

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.test" android:versionCode="1" android:versionName="1.0.0" android:configChanges="keyboardHidden|orientation">
        <uses-sdk android:minSdkVersion="7"/>
        <application android:icon="@drawable/icon" android:label="Test">
            <activity android:name=".Test" android:label="Test" android:debuggable="true" android:theme="@android:style/Theme.NoTitleBar" android:launchMode="singleTask">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>
            <activity android:name=".Searchable">
                <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>
            <meta-data android:name="android.app.default_searchable" android:value=".Searchable"/>
        </application>
    </manifest>

Searchable.xml (res/xml/searchable.xml)

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

Searchable.java (src/com/test/test/Searchable.java)

package com.test.test;

import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;

public class Searchable extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        handleIntent(getIntent());
    }
    @Override
    protected void onNewIntent(Intent intent) {
        setIntent(intent);
        handleIntent(intent);
    }
    private void handleIntent(Intent intent) {
        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            String query = intent.getStringExtra(SearchManager.QUERY);
        }
    }
}

TIA,

ng93

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:03:51+00:00Added an answer on May 19, 2026 at 2:03 am

    Your Searchable activity has to do something – and actually display results.

    I just wrote one as suggested by an answer to a question I asked yesterday Trying to filter a ListView with runQueryOnBackgroundThread but nothing happens – what am I missing?

    Look at this documentation for how to integrate with the built in search support: Using the Android Search Dialog and look at this article on how to offer suggestions as the customer types: Adding Custom Suggestions

    Your class Searchable needs to do a bit more after getting the query string. For example in my activity after getting the query string I do this:

            showResults(query);
    

    and that method looks like this:

    private void showResults(String query)  {
        //  Load the list of countries based on the query
        Cursor countryCursor = myDbHelper.getCountryList (query);
        startManagingCursor (countryCursor);
    
        //  Hook up the query results to the list view
        String[] from = new String[]  {
            WorldInfoDatabaseAdapter.KEY_COUNTRYCODE, WorldInfoDatabaseAdapter.KEY_COUNTRYNAME
        };
        int[] to = new int[]  {
            R.id.countryflag, R.id.countryname
        };
        SimpleCursorAdapter adapter = new SimpleCursorAdapter (this,
                R.layout.country_list_row, countryCursor, from, to);
        adapter.setViewBinder (new FlagViewBinder ());
    
        myCountryList.setAdapter (adapter);
        myCountryList.setOnItemClickListener (new OnItemClickListener () {
    
            @Override
            public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
                String countryName = myDbHelper.getCountryByID (id);
                if (countryName == null)  {
                    new AlertDialog.Builder (SelectCountryActivity.this).setMessage (
                            "Internal error: Cannot find the country with id'" + id + "'.").show ();
    
                    return;
                }
    
                //  Package up the country name to return
                Intent newCountryIntent = new Intent (myCountryList.getContext (), WorldInfoActivity.class);
                newCountryIntent.putExtra (WorldInfoActivity.KEY_SELECTED_COUNTRY, countryName);
                startActivity (newCountryIntent);
    
                startActivity (newCountryIntent);
                finish ();
            }
        });
    }
    

    The member myDbHelper queries my database for countries that have the passed in query string and displays them in a list. My activity has a layout that looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        style="?pageBackground">
        <TextView
            android:id="@+id/selectdlgtitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/select_country_title"
            style="?dlgTitle" />
        <ListView
            android:id="@+id/countrylist"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:cacheColorHint="#00000000"
            android:padding="2px"/>
        </LinearLayout>
    

    You can probably do without the setViewBinder call – I need that because I am translating the country code field into a flag icon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use a guid as a resource id in a rest url but
I was writing a Blog like application Using Rails3/Mongoid, and now trying to use
I am trying use filehelpers class builder but I am kinda confused on what
I am trying use std::copy to copy from two different iterator. But during course
I am trying to implement two different searchable activities, one for honeycomb(with search widget)
I am trying use Thread but i have some problem (I am beginner at
I'm trying use double type in openCL, but doesn't work anyway, i want use
I am trying use the onClick() function in an activity for an android app.
Im trying use a Java annotation in a Groovy class but have trouble to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.