including list_content into list layout to retain ListFragment functionality

后端 未结 3 571
南方客
南方客 2021-02-05 11:47

First of, I\'m using The Android Compatibility Library V4 rev.3 for my 1.6(Donut)

When you first create a ListFragment it displays an indeterminant progress indicator u

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 12:05

    One possible work-around to incorporate default @android.R.layout/list_content into custom layout when using compatibility library is to create a dummy ListFragment:

    package com.example.app;
    
    import android.support.v4.app.ListFragment;
    
    public class ListContentFragment extends ListFragment {
        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
            //Supress default list and empty text behavior
            //super.onViewCreated(view, savedInstanceState);
        }
    }
    

    Then including this fragment (instead of recommended list_content layout) into your custom layout:

    ...
    
    ...
    

    This way you'll get a fully functional default behavior of the ListFragment while still having custom layout for it.

提交回复
热议问题