2016-03-20 24 views
0

我需要创建一个动态的表单列表。用户将能够将数据输入到列表的每个元素(其中将包含可编辑的文本框和其他元素)。在Android中创建表单的ListView的最佳策略?

什么是最好的方法?我将如何访问每个列表元素中的输入信息?每个列表元素都必须是它自己的片段吗?

回答

0
1) Decide what elements you need in each list item 
2) Create a data class with the member variables to how your data. one data object will be initialized per listview item //note this is not required, but it can help. 
3) Create a layout (list_view_item_layout.xml) for your listview items 
4) Declare your ListView in your layout.xml, ensure that you give it an android:id. 
5) Declare and initialize an array of your data objects (or just an array of data) that holds all the data objects that you want displayed in your list 
5) Create your MyListViewAdapter.class that extends BaseAdapter. this class will inflate your list_view_item_layout and populate the views with the data that is in your data array 
6) call ListView#setAdapter(); passing in myListViewAdfapter, context, R.id.document_list_view //I htink that is correct 

这就是关于它的一切。 寻找自定义列表视图适配器的教程,有十亿+教程