1
我已经看到关于如何将活动转换为ListActivity来填充ListView的各种教程,但没有ListFragments。我有两个选项卡,每个选项卡下都有一个片段。这是我的片段目前的样子....可以有人给我一些想法,我怎么能做到这一点?如何在Android中填充ListFragment?
public class MainFragment extends ListFragment {
String[] items = { "12 Monkeys", "(500) Days of Summer", "Chariots of Fire" };
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.fragment_main, container, false);
}
}
这里是XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
我试图让items
在ListView显示。