【发布时间】:2013-12-30 05:40:54
【问题描述】:
是否可以在 Fragment 类中自定义 ListView?
这是我的片段类,其中fragment_find_people 只是一个空的XML:
public class FindPeopleFragment extends Fragment {
public FindPeopleFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_find_people, container, false);
return rootView;
}
}
现在,我已经有了一个 customListView,但它只适用于 Activity 类。我怎样才能把它转给Fragment?
我的 listview_main xml
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listmain" >
<ListView
android:id="@+id/listview"
android:layout_marginTop="10dp"
android:background="@drawable/bg"
android:divider="#9c9c9c"
android:dividerHeight="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent" /></RelativeLayout>
【问题讨论】:
-
@EugenMartynov 我使用的是片段类而不是活动类
-
@user3138250 发布更多代码。你为此做了什么?
-
@user3138250 你有没有试过用一些数据绑定listview?
-
我在 Activity 类中尝试过,但在 Fragment 类中还没有尝试过
标签: android listview android-fragments android-fragmentactivity