我是android的编程新手现在我的工作暂停,因为我没有得到如何完成以下我想创建一个具有分页功能的视图,在视图中会有textview显示人的名字和他所有亲戚的名字列表....而且列表可以很长,所以它应该是可滚动的...我知道要独立进行分页和列表,但不知道如何在一个视图中将两者结合起来......我希望我对自己的问题很清楚......所以大家帮我解决了这个问题......
答案 0 :(得分:1)
I know to do paging and list independently but do not know how to combine the both in one view
所以你可以像这样创建xml:
线性布局/相对布局
文字视图
列表视图
将此XML放入片段
编辑:
public class Fragment1test extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
//This layout contains your list view
View view = inflater.inflate(R.layout.your_view_xml, container, false);
//now you must initialize your list view
Listview listview =(Listview)view.findViewById(R.id.your_listview);
//Here items must be a List<Items> according to your class instead of String[] array
ListAdapter listadapter = new ListAdapter(getActivity(), android.R.layout.simple_list_item_1, items)
ListView.setAdapter( listAdapter());
//getActivty is used instead of Context
return view;
}
}