【问题标题】:Best strategy to create a ListView of forms in Android?在 Android 中创建表单 ListView 的最佳策略?
【发布时间】:2016-03-20 08:34:53
【问题描述】:

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

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

【问题讨论】:

    标签: android forms list listview fragment


    【解决方案1】:
    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
    

    这就是它的全部内容。 寻找自定义列表视图适配器的教程,有十亿以上的教程

    【讨论】:

      猜你喜欢
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      • 2020-04-29
      • 1970-01-01
      • 2020-06-06
      • 2015-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多