Code example for ListFragment

Methods: onViewCreatedsetListAdapter

0
        adapter = new PostAdapter(getActivity(), R.layout.post_item, posts, this);
    } 
 
    @Override 
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setListAdapter(adapter);
    } 
 
    public void setData(ArrayList<Post> data, ArrayList<String> links) {
        posts.clear();
        posts.addAll(data);
 
        threadLinks.clear();
        threadLinks.addAll(links);
 
        if (adapter != null) {
            adapter.notifyDataSetChanged();
        } 
    }