hamedjj
hamedjj

Reputation: 658

Android - show TextView when the GridView is empty

I have favorite page with gridview for wallpaper app. sometimes this page for user is empty

I wanna show the textview "There is no item" when the gridview is empty

what should i do?

thanks

Upvotes: 0

Views: 854

Answers (1)

Msp
Msp

Reputation: 2493

Use a TextView as empty view.

TextView emptyView = (TextView)findViewById(android.R.id.empty);
emptyView.setText("There is no item");
gridView.setEmptyView(emptyView);

This will show the empty message when GridView is empty.

Upvotes: 3

Related Questions