2016-03-20 47 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 

這就是關於它的一切。 尋找自定義列表視圖適配器的教程,有十億+教程