Fragment作为Activity的片段,在安卓开发中被使用的频率非常高,同时ListView作为最常用的控件,因此在Fragment中加载ListView也是非常常用的,下面介绍一下具体的Fragment中加载ListView的步骤:
1)定义一个继承自ListFragment的Fragment(TestFragment);
2)在xml中,要加载的ListView的id必须设置为 android:id="@+id/android:list" !!! 而在代码中ListView的名称必须设置为LIst
3)只能使用SimpleAdapter或者是SimpleCursorAdapter(与数据库打交道的Aapter)作为适配器