Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty list #11

Open
ilandbt opened this issue Dec 14, 2014 · 1 comment
Open

Empty list #11

ilandbt opened this issue Dec 14, 2014 · 1 comment

Comments

@ilandbt
Copy link

ilandbt commented Dec 14, 2014

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);
    }
}
@ilandbt ilandbt changed the title null pointer exception in setAdapter Empty list Dec 14, 2014
@lawloretienne
Copy link
Owner

@ilandbt What does your layout file fragment_new_home_layout.xml look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants