I am wanting to display a text field stating that my listview is empty if there is nothing in my list. I know this can be accomplished quite simply using an android:id/empty textview in the xml file, but this also requires that I extend my activity with something other than Activity and I don't want to do that.开发者_如何学Go
I guess my only solution is to create a textview and then set its visibility to gone when my code detects that something has been added to the listview. I can simply check the array that populates the list, but is there some sort of listener so I don't have to run a checkListIsEmpty() constantly throughout the code. I was hoping I could use something that would simply sit quiet and wait for the listview to become populated and when that happened change the visibility to visible and then begin waiting for it to become empty again.
Or you can use setEmptyView(View v)
on your ListView
in your Activity
.
精彩评论