Display “No Item” message in ListView

后端 未结 6 1582
清酒与你
清酒与你 2020-12-07 20:31

I\'ve created some composie UIs in my android apps and there are some ListView controls -among other controls- inside a view. Because of this, I have used \"Activity\" as my

6条回答
  •  一个人的身影
    2020-12-07 21:06

    The easiest way to achieve this was using a ListFragment instead of a ListActivity. ListFragment has the following convenience method:

    setEmptyText("My no items message...");
    

    Besides, using a ListFragment class has other advantages. For example, the possibility to combine it with the new AppCompat library (which you cannot do with ListActivity because you have to extend from ActionBarActivity).

提交回复
热议问题