How to show the alert dialog for the empty list view when there are no listview items. Please find the below image having three text fields. I have to implement the empty list view when there are no records/unmatched records in the list.
The list view is implemented as below:
ListView empListView;
empListView = (ListView)findViewById(R.id.list1 );
I have to show the alert dialog box for the empListView. Please help me with the samplecode/links.
I think you are paasing arraylist or some other data in setadapter method And if you are using arraylist then you have to check that size of arraylist before calling the setadapter method.
It all depends on how you implement the setAdapter method etc. But here is an example:
The code above havent been tested. But should work with minor adjustments, I might have forgotten something.
I think you are paasing arraylist or some other data in setadapter method And if you are using arraylist then you have to check that size of arraylist before calling the setadapter method.
As per my opinion, No need to check the size of arraylist or adapter item count.
Instead of displaying alert dialog, you can just display message "Sorry no records found" message on the listview. for the same you have to set the empty view by using
setEmptyView()
method of ListView.For example: