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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:48:45+00:00 2026-06-12T01:48:45+00:00

I am implementing the custom suggestion list for search activity from this blog http://weblog.plexobject.com/?p=1689

  • 0

I am implementing the custom suggestion list for search activity from this blog http://weblog.plexobject.com/?p=1689 in doSearchQuery not able understand what he did it. Another thing is when I search by typing for e.g. month name and start with the “A” it compare it and return those match result August, April etc. but in the suggestion list only display “a” with all match result like “j” is contain in January, June, July. But in suggestion list getting j, j, j only not this months name. where I am wrong or missing something I didn’t understand

here is my code for SearchActivity

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.search_activity);
    this.setDefaultKeyMode(Activity.DEFAULT_KEYS_SEARCH_LOCAL);

    final Intent queryIntent = getIntent();

    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
        this.doSearchQuery(queryIntent);
    } else if (Intent.ACTION_VIEW.equals(queryAction)) {
        this.doView(queryIntent);
    } else {
        Log.d(TAG, "Create intent NOT from search");
    }

}

@Override
public void onNewIntent(final Intent queryIntent) {
    super.onNewIntent(queryIntent);
    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
        this.doSearchQuery(queryIntent);
    } else if (Intent.ACTION_VIEW.equals(queryAction)) {
        this.doView(queryIntent);
    }
}
// here in this didn't under what he did one is getting intent and bundle but where he define it.
private void doSearchQuery(final Intent queryIntent) {
    String queryString = queryIntent.getDataString(); // from suggestions
    if (query == null) {
        query = intent.getStringExtra(SearchManager.QUERY); // from search-bar
    }

    // display results here
    bundle.putString("user_query", queryString);
    intent.setData(Uri.fromParts("", "", queryString));

    intent.setAction(Intent.ACTION_SEARCH);
    queryIntent.putExtras(bundle);
    startActivity(intent);
    Log.e("query string", "query string "+queryString);
}

private void doView(final Intent queryIntent) {
    Uri uri = queryIntent.getData();
    String action = queryIntent.getAction();
    Intent intent = new Intent(action);
    intent.setData(uri);
    startActivity(intent);
    this.finish();
}

here is my Provider, I need single line suggestion I am comment the second column

public class MySuggestionProvider extends SearchRecentSuggestionsProvider {
    public final static String AUTHORITY = MySuggestionProvider.class.getName();
    public final static int MODE = DATABASE_MODE_QUERIES;
    private final static String TAG = MySuggestionProvider.class.getSimpleName();

    private static final String[] COLUMNS = {
            "_id", // must include this column
            SearchManager.SUGGEST_COLUMN_TEXT_1,
//          SearchManager.SUGGEST_COLUMN_TEXT_2,
            SearchManager.SUGGEST_COLUMN_INTENT_DATA,
            SearchManager.SUGGEST_COLUMN_INTENT_ACTION,
            SearchManager.SUGGEST_COLUMN_SHORTCUT_ID };

    public MySuggestionProvider() {
        setupSuggestions(AUTHORITY, MODE);
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection,
            String[] selectionArgs, String sortOrder) {

        String query = selectionArgs[0];
        if (query == null || query.length() == 0) {
            return null;
        }

        MatrixCursor cursor = new MatrixCursor(COLUMNS);

        try {
            List<String> list = callmyservice(query);
            int n = 0;
            for (String obj : list) {
                cursor.addRow(createRow(Integer.valueOf(n), query, obj));
                n++;
            }
        } catch (Exception e) {
            Log.e(TAG, "Failed to lookup " + query, e);
        }
        return cursor;
    }

    @Override
    public Uri insert(Uri uri, ContentValues values) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        throw new UnsupportedOperationException();
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection,
            String[] selectionArgs) {
        throw new UnsupportedOperationException();
    }

    private Object[] createRow(Integer id, String text1,
            String name) {
        return new Object[] { id, // _id
                text1, // text1
                //text2, // text2
                text1, "android.intent.action.SEARCH", // action
                SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT };
    }
    private static final String[] months = {"January", "February","march","April","may","june","july","August","September","octobor",
        "november","december"};
    List<String> ls2 = new ArrayList<String>();
    private List<String> callmyservice(String query){
        List<String> ls = new ArrayList<String>();

        for(int i=0;i<months.length;i++){
            if(months[i].toLowerCase().contains(query.toLowerCase())){
                //if(months[i].equalsIgnoreCase(query.toLowerCase())){
                ls.add(months[i]);
            }
        }

        ls2.clear();
        ls2.addAll(ls);

        return ls;
    }
}
  • 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-12T01:48:46+00:00Added an answer on June 12, 2026 at 1:48 am

    I find the way how to implement custom suggestion. A little bit changes in this and you can implement search Suggestion Single or as Double line in suggestion list.

    For the Single line suggestin I am explain first.

    As from the questions code I changes some and implement the for single line suggestion list.

    From the COLUMN object change this

    private static final String[] COLUMNS = {
            "_id", // must include this column
            SearchManager.SUGGEST_COLUMN_TEXT_1,
            SearchManager.SUGGEST_COLUMN_INTENT_DATA,
            SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA,
            SearchManager.SUGGEST_COLUMN_SHORTCUT_ID };
    

    now in createRow() time just pass the object one is ID and another is suggestion list value in query() method.

    List<String> list = callmyservice(query);
    int n = 0;
    for (String obj : list) {
         cursor.addRow(createRow(Integer.valueOf(n),obj));
          n++;
    }
    

    now implement the createRow() like this.

    private Object[] createRow(Integer id, String text1){
        return new Object[] { id, // _id
                text1, // text1
                text1, // data to sent back to activity and select
                text1, // data sent as extra data when select from suggestin list
                SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT};
    }
    

    Ok here is the snap hows it look when you implement this.

    enter image description here

    Ok Now for two line search suggestion list create COLUMN object like this

    private static final String[] COLUMNS = {
            "_id", // must include this column
            SearchManager.SUGGEST_COLUMN_TEXT_1,
            SearchManager.SUGGEST_COLUMN_TEXT_2,
            SearchManager.SUGGEST_COLUMN_INTENT_DATA,
            SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA,
            SearchManager.SUGGEST_COLUMN_INTENT_ACTION,
            SearchManager.SUGGEST_COLUMN_SHORTCUT_ID };
    

    now implement createRow() method and call from query() like this
    // query() method
    List list = callmyservice(query);
    int n = 0;
    for (String obj : list) {
    // here query is your current typing text for search for text_1
    // obj was the match list found with this query as result and display for text_2
    cursor.addRow(createRow(Integer.valueOf(n), query, obj));
    n++;
    }

    private Object[] createRow(Integer id, String text1, String name) {
        return new Object[] { id, // _id
                text1, // text1
                text2, // text2
                text1, // data to be sent when select from list as query
                text2, // data to be sent as extra string when select from list as result
                "android.intent.action.SEARCH", // action
                SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT };
    }
    

    and here is the view for two line search suggestion list

    enter image description here

    ok so hope that this will helpful to you.

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

Sidebar

Related Questions

I am having problem with implementing custom session handler in php. The code: http://pastebin.com/9QV9f22Q
I'm implementing a custom calendar using a GridView. For this Calendar I have 3
I'm implementing a custom control that inherits from Control . I want it to
I'm implementing a custom BCS Model to get data from a backend system. As
I was reading custom serialization article on msdn: http://msdn.microsoft.com/en-us/library/ty01x675%28VS.80%29.aspx It mentions that there are
I'm implementing the Soundcloud custom player ( https://github.com/soundcloud/soundcloud-custom-player ) on my site. I would
I'm looking for some pointers on implementing Custom Events in VB.NET (Visual Studio 2008,
Implementing a custom Dependency Property on a Framework Element object causes my Visual Studio
Implementing a custom membership provider, there are certain properties such as MinRequiredPasswordLength that only
I'm implementing a custom UIButton with minimal functionality. The .h file: #import <Foundation/Foundation.h> @interface

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.