Issue using setEmptyView on a ListActivity

后端 未结 3 2017
抹茶落季
抹茶落季 2020-12-30 18:19

I have the following setup, and the empty view text doesn\'t show up...

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstance         


        
相关标签:
3条回答
  • 2020-12-30 18:47

    I was missing a setContentView(R.layout.listview); and because of this the view was not picked upped by findViewById.

    0 讨论(0)
  • 2020-12-30 18:59

    Shouldn't

    <ScrollView
            android:id="@android:id/empty"
    

    be

    <ScrollView
            android:id="@+id/empty"
    

    ? I don't know if that makes any difference.

    Are you sure that setListAdapter(null); actually initializes the Adapter, rather than just ignoring the command?

    0 讨论(0)
  • 2020-12-30 19:06

    In fact, you doesn't need this line in your java code

    getListView().setEmptyView(findViewById(R.id.empty));

    The couple of Android ID android:id="@android:id/list" and android:id="@android:id/empty" are exclusive !

    Best regards, Division-par-zero.

    0 讨论(0)
提交回复
热议问题