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

  • Home
  • SEARCH
  • 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 8280311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:37:50+00:00 2026-06-08T09:37:50+00:00

How can I convert an ArrayAdapter<String> of static data into a CursorAdapter for using

  • 0

How can I convert an ArrayAdapter<String> of static data into a CursorAdapter for using Suggestion Listener in SearchView?
I have constructed the ArrayAdapter<String> from static data (allString)

ArrayAdapter<String> searchAdapter = new ArrayAdapter<String>(context, R.layout.listitem, allString);

and I use it for an MultiAutoCompleteTextView which works fine in devices with API level less than 11

MultiAutoCompleteTextView findTextView.setAdapter(searchAdapter);

However my target API is level is 11 and for API>10 I use an ActionBar within which I would like to have a SearchView instead.

Here’s what I have tried: It does show the ActionBar with the embedded SearchView but does not give any suggestions as it would in the MultiAutoCompleteTextView.

@Override
public boolean onCreateOptionsMenu(Menu menu) {     
        MenuInflater inflater = getMenuInflater();

         if (android.os.Build.VERSION.SDK_INT > 10){
             inflater.inflate(R.menu.menu11, menu);
             searchView = (SearchView) menu.findItem(R.id.MENU_SEARCH).getActionView();
             int[] to = {0};
             CursorAdapter cursorAdapter = new SimpleCursorAdapter(context, R.layout.listitem, null, allBusStopString, to);
             searchView.setSuggestionsAdapter(cursorAdapter);
             searchView.setOnSuggestionListener(new OnSuggestionListener() {

                @Override
                public boolean onSuggestionClick(int position) {
                    String selectedItem = (String)cursorAdapter.getItem(position);
                    Log.v("search view", selectedItem);
                    return false;
                }

                @Override
                public boolean onSuggestionSelect(int position) {
                    return false;
                }
             });  
         }else{
             inflater.inflate(R.menu.menu, menu);
         }

    return true;
}
  • 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-08T09:37:54+00:00Added an answer on June 8, 2026 at 9:37 am

    That’s strange SearchView.setSuggestionsAdapter accepts CursorAdapter only.

    You could create MatrixCursor and fill it with data from String array. I hope you have small data collection.

    Then pass the cursor to CursorAdapter.

    String[] columnNames = {"_id","text"}
    MatrixCursor cursor = new MatrixCursor(columnNames);
    String[] array = getResources().getStringArray(R.array.allStrings); //if strings are in resources
    String[] temp = new String[2];
    int id = 0;
    for(String item : array){
        temp[0] = Integer.toString(id++);
            temp[1] = item;
        cursor.addRow(temp);
    }               
    String[] from = {"text"}; 
    int[] to = {R.id.name_entry};
    busStopCursorAdapter = new SimpleCursorAdapter(context, R.layout.listentry, cursor, from, to);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can convert an integer into string using String s = + 4; //
I know that you can convert a float into a string using NSString *myString
How can convert a certain file into in a String? And then from that
How can I convert a number contained in a string from any base to
In Specman I can convert a variable to a string using either: x.to_string(); or
The SQL Server convert () function can convert varbinary data to a string with
When I have access to UrlHelper I can convert an ActionResult to a string
I can convert html files to pdfs with iTextSharp using code from Kyle in
In MSSQL you can convert a string into an integer like this: CONVERT(INT, table.column)
How I can convert the following methods to C# 2.0? private static string ToHexString(byte[]

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.