I have a gridview that is populated by a cursor that fetches data from SQLITE database. At times, there is no data to be shown. This shows a blank activity.
I had earlier used listview where I could use @android:id/empty to set an emptyView like "no data found".
Is there any similar feature for GridView that I can make use of?
Kindly help.
ListActivity and ListFragment
simply search for a view with that ID and call
listView.setEmptyView(emptyView);
You can mimic this behavior in your GridView
..
TextView emptyView = (TextView)findViewById(android.R.id.empty);
gridView.setEmptyView(emptyView);
Note that you don't need to set your empty view's ID to @android:id/empty
. It can be anything you want as long as you are setting it in code.
Link to GridView setEmptyView docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With