Theresa Gamit
Theresa Gamit

Reputation: 302

How to display "no result(s) found" using searchview in android

Here is my code in "if (cursor == null)." As you can see, I don't put any code there because I don't know how to display "no result(s) found" in the ListView if the user doesn't match his input to the searchview. I'm using ListView to display the search results of the user.

Cursor cursor = mDbHelper.searchCrvJapanesealpha((query != null ? query.toString() : "@@@@"));
if (cursor == null) {

} else {

    // Specify the columns we want to display in the result 
    String[] from = new String[] {
        DBAdapter.KEY_JAPANESECHAR,
        DBAdapter.KEY_JAPANESEALPHA};

I'm just beginner with Android.

Upvotes: 0

Views: 2357

Answers (2)

pskink
pskink

Reputation: 24720

read about empty view, for example: http://cyrilmottier.com/2011/06/20/listview-tips-tricks-1-handle-emptiness/

Upvotes: 0

Hardik Joshi
Hardik Joshi

Reputation: 9507

Create one TextView with text "no result(s) found" after listview. Now defalut visibility of TextView is gone. Now if condition is true set visibility of TextView to true and listview to gone.

Upvotes: 1

Related Questions