所以抛出的错误是
java.lang.IllegalStateException: Content view not yet created
当我取消注释该getListView().setOnScrollListener(this);
行时会抛出此问题。
public class MyCategoryFragment extends ListFragment implements OnScrollListener {
private ArrayList<Article> m_articles = new ArrayList<Article>();
public ArticleAdapter m_artadapter;
public MyCategoryFragment() {
super();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_category, container, false);
m_articles = manager.loadCategory(getActionBar().getTitle().toString(), 10);
m_artadapter = new ArticleAdapter(this.getActivity(), R.layout.article_button, m_articles);
this.setListAdapter(m_artadapter);
//getListView().setOnScrollListener(this);
return rootView;
}
这是布局,您可以看到它是正确的列表视图
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:id="@android:id/empty"
android:textColor="#FFFFFF"
android:textSize="30sp"
android:gravity="center_vertical|center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="It's not you it's us..."/>
</LinearLayout>
我对此进行了广泛的研究,我相信一定很简单,但要解决这个问题需要一天多的时间。谢谢