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 8733361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:38:02+00:00 2026-06-13T09:38:02+00:00

I used the officical Android sample code SearchableDictionary (Link: http://jayxie.com/mirrors/android-sdk/resources/samples/SearchableDictionary/index.html ), that gives us

  • 0

I used the officical Android sample code “SearchableDictionary” (Link: http://jayxie.com/mirrors/android-sdk/resources/samples/SearchableDictionary/index.html), that gives us a search interface, where you can search for a word and you have 2 options:

1- Put your keyword and click on search icon (keyboard), so a listview for all matched results will appear. You click on a word in the ListView to retrieve the definition.

2- Put your keyword and a little list of suggestion will appear automatically every time the searchView keyword changes, so you can click on a suggestion to retrieve her definition.

This is the code of the search function called when you click on an item in the big listview, not in the list of suggestions.

     private void doSearch(String queryStr) { 
            // get a Cursor, prepare the ListAdapter and set it
     final DataBaseHelper myDbHelper = new DataBaseHelper(this);
     myDbHelper.openDataBase();
     Cursor cursor = managedQuery(DictionaryProvider.CONTENT_URI, null, null,
             new String[] {queryStr}, null);
    //Cursor cursor = myDbHelper.fetchListItems(queryStr);
    //cursorr.moveToFirst(); // moves the cursor to the first row in the result set, returns false if the result set is empty.

    startManagingCursor(cursor); /* Managing cursors take care of closing the cursor when
    the activity is destroyed, but they do more than that as well: they will be
    deactivated and required as the activities is stopped and restarted. */

    // set the custom list adapter
    // setListAdapter(new MyListAdapter(this, cursor));

     // Specify the columns we want to display in the result
     String[] from = new String[] { DataBaseHelper.KEY_WORD,
                                    DataBaseHelper.KEY_DEFINITION };

     // Specify the corresponding layout elements where we want the columns to go
     int[] to = new int[] { R.id.title,
                            R.id.details };

     // Create a simple cursor adapter for the definitions and apply them to the ListView
     SimpleCursorAdapter words = new SimpleCursorAdapter(this,
                                   R.layout.list_item_with_description, cursor, from, to);
     final ListView mListView = (ListView) findViewById(R.id.list);
     mListView.setAdapter(words);
    // search_keyword = queryStr ;

     // Define the on-click listener for the list items
     mListView.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


             // Build the Intent used to open WordActivity with a specific word Uri
             Intent wordIntent = new Intent(getApplicationContext(), DefinitionActivity.class);
            // final Bundle bundle = new Bundle();


             Uri data = Uri.withAppendedPath(DictionaryProvider.CONTENT_URI,
                                             String.valueOf(id));


             Log.d(TAG,"clicked row id="+id);

             wordIntent.setData(data);
             wordIntent.putExtra("clicked_item_id",id);

             startActivity(wordIntent);
         }
     });

As you can see we can handle the items clicked in the list of matched words, but how can i handle the suggestions clicked in the little list of suggestions? I want to catch the id of the clicked suggestion, not the clicked item in the big listview. How can I make this?

  • 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-06-13T09:38:03+00:00Added an answer on June 13, 2026 at 9:38 am

    When a search suggestion is clicked, an Intent is sent to your searchable activity. You can simply define the Action field of this Intent though your searchable XML by configuring the android:searchSuggestIntentAction attribute like this:

    <searchable 
    ...
        android:searchSuggestIntentAction = "android.intent.action.VIEW">
    

    And then, in your searchable Activity:

    Intent intent = getIntent();
    if (Intent.ACTION_VIEW.equals(intent.getAction()) {
        //a suggestion was clicked... do something about it...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Used code I found on SO to use the COM based Acrobat Reader to
I used Jquery to insert a variable to div. Please check my code. var
i used this code: List<string> lists=new List<string>(apple,orange,banana,apple,mang0,orange); string names; names=lists.Distinct() is that correct?
I am looking for a solution for facebook connect for Android. Before I used
code: <script src=http://www.openlayers.org/api/OpenLayers.js></script> <script type=text/javascript> map = new OpenLayers.Map(open_map); map.addLayer(new OpenLayers.Layer.OSM()); var lonLat =
One of the latest updates for the Android SDK plugin in Eclipse introduced a
List sections are used quite a lot in Android through out Google's own applications
On official Sencha downloads page - http://www.sencha.com/products/extjs/download/ those versions are between v 3.3 and
In the official boost link below: http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/reference/deadline_timer.html . You can see we can renew
Used to be quite happy with the Ctrl + Shift + F10 shortcut in

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.