Skip to content

Empty list #11

Description

@ilandbt

Hi,
I am trying to use the example in the Readme and my list is shown empty

(i have a custom adapter)

any suggestions?

CODE:

public class FragmentNewHome extends Fragment{

    //views
    private ViewGroup rootView;
    //private LinearLayout footer;
    private Button b1, b2, b3, b4;
    //private ListView list;


    private ArrayList<ListItem> data;
    public AdapterHomeList adapter;

    @InjectView(R.id.new_home_footer) LinearLayout footer;
    @InjectView(R.id.new_home_listview) ListView list;


    public FragmentNewHome(){
    }

    public static FragmentNewHome newInstance() {
        FragmentNewHome fragment = new FragmentNewHome();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }


    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement interfaces");
        }
    }

    @Override   
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = (View) inflater
                .inflate(R.layout.fragment_new_home_layout, container, false);

        ButterKnife.inject(this, view);


        return rootView;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        data = new ArrayList<ListItem>();


        data.add(new ListItem("test1"));
        data.add(new ListItem("test2"));
        data.add(new ListItem("test3"));

        adapter = new AdapterHomeList(data, getActivity());

        Log.e("test", "adapter: " + (adapter == null ? "null" : "not null"));
        Log.e("test", "list: " + (list == null ? "null" : "not null"));

        list.setAdapter(adapter);

        QuickReturnListViewOnScrollListener scrollListener = new QuickReturnListViewOnScrollListener(QuickReturnType.FOOTER,
                null, 0, footer, 60);

        scrollListener.setCanSlideInIdleScrollState(true);
        list.setOnScrollListener(scrollListener);


    }



    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions