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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:07:49+00:00 2026-06-07T22:07:49+00:00

I am trying to figure out a search interface for Android. My first question

  • 0

I am trying to figure out a search interface for Android. My first question has to do with implenting the listview. I am using a search widget on the action bar. Here is the opening code:

public class SearchableActivity extends ListActivity {

  // class fields

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);

    ListView lv = (ListView) findViewById(android.R.id.list);
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {



        }
    });

    // Get the intent, verify the action and get the query
    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        query = intent.getStringExtra(SearchManager.QUERY);

        ProgressDialog dialog = ProgressDialog.show(
                SearchableActivity.this, "Searching",
                "Searching. Please wait...", true);

        performSearch(query);

        dialog.hide();
        dialog.dismiss();
    }
}

public void performSearch(String query) {
    List<String> dataList = new ArrayList<String>();


    dataList = new ArrayList<String>();
    new task().execute(); // Task calls an HttpPost and opens search through php and populates list through JSON


    ArrayAdapter<String> arr = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, dataList);
    this.setListAdapter(arr);

}
  1. In first method I am setting up a ListView, I am not sure what code I need to do onClick? Where does the search results go? I’d like to display closest results as the user types.
  2. Not sure where to put the xml R.id.list? Is it built in to the widget as a drop down? (e.g. the search widget in Play Store)
  3. Also, is my implementation of using a Task correct in this and sending the query to php?
  • 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-07T22:07:51+00:00Added an answer on June 7, 2026 at 10:07 pm
    In first method I am setting up a ListView, I am not sure what code I need to do onClick?
    Where does the search results go? I'd like to display closest results as the user types.
    

    If you want to perform a action on list item i.e. a row ..Like you have a List of Product and OnClick you want to display the details of your product then you launch your new Activity which shows details of that related product.

    Not sure where to put the xml R.id.list? Is it built in to the widget as a drop down? (e.g. the search widget in Play Store)
    

    No need to add it in your search.xml like..

        <ListView
      android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" >
    </ListView> 
    

    For more read this.

    Also, is my implementation of using a Task correct in this and sending the query to php?
    

    NO, Use AsyncTask.

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

Sidebar

Related Questions

I am trying to figure out how the search tool in a web browser
I'm trying to figure out how to search for other devices logged into a
I have the following and I am trying to figure out how to search
I'm trying to figure out if there's a way I can search for a
I've been trying to figure out a command that will search through 13+ files
I'm trying to figure out how to do a pixel (color) search from the
I am trying to figure out how to search for a book by ISBN
was looking over this program and im trying to figure out how to search
I'm inexperienced with SQL... i'm trying to figure out how to search my database
I am trying to figure out how to add search to my rails application.

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.