How to get the value of android activity?

How can I get the text entered into a search box in android?

  • I am creating my first real android app. I have an action bar with a search widget in it, and I do not know how to get the entered search term and do something with it. I want to be able to get the search term then query it to an online api and return the results in a list view. Here is my code so far: My main activity looks like this: http://pastebin.com/Pi4zJpRT and I am getting this error: The method setOnQueryTextListener(SearchView.OnQueryTextListener) in the type SearchView is not applicable for the arguments (new OnQueryTextListener(){})

  • Answer:

    To fix this error, try importing OnQueryTextListener class. Would recommend you to look into android sample application - SearchableDictionary that comes with the Android SDK samples and this tutorial - http://developer.android.com/training/search/index.html Though this tutorial shows you how to create a SQLite virtual table that is populated from "definitions.txt" file inside resources/raw folder, you can modify it to fetch data from an online database.

Ashita Agrawal at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.