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

これはすべてです。 カスタムリストビューアダプターのチュートリアルを探して、10億個のチュートリアルがあります

関連する問題