2014-12-02 70 views

回答

5

你应该通过一个Context对象为您CustomListAdaptor的构造函数的第一个参数,但你传递一个Fragment objecy代替。 试试这个:

CustomListAdaptor customListAdaptor = new CustomListAdaptor(getActivity(), list); 
+0

感谢快速的解决方案,非常感谢先生。 – 2014-12-02 22:06:05

+0

欢迎你的家伙! ;) – 2014-12-02 22:13:27

1

您的问题是在这条线

CustomListAdapter customAdapter = new CustomListAdapter(this, list); 

更具体的关键字是你的问题。您正试图通过这个作为Context,它在一个活动中工作,因为活动Context。但是,片段不需要

所以你必须调用父活动的Context像这样:

CustomListAdapter customAdapter = new CustomListAdapter(getActivity(), list);