Empty Listview Inside Of Fragment
I have a vertical LinearLayout and a Listview and a big Button inside. All is inside of a Fragment. What I want to do is to show empty list when nothing is found after performing s
Solution 1:
Add the emptyView (TextView
, ImageView
, any View
implementation you wish) in your fragment layout, make it visible="gone"
and use that instead of what you currently have. So the code should change to this:
ListView list2=(ListView)rootView.findViewById(R.id.scans_list);
View emptyView = rootView.findViewById(R.id.my_empty_view);
list2.setEmptyView(emptyView);
In this way, when the adapter checks if it's empty, the listView will automatically change its visibility to GONE and the empty view, if it exists (in your case, true), will be set to VISIBLE.
Post a Comment for "Empty Listview Inside Of Fragment"