使用 ListView 进行内联编辑是否可以?

编程入门 行业动态 更新时间:2024-10-28 18:21:51
本文介绍了使用 ListView 进行内联编辑是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我无法写入 EditText,当我尝试写入时它会消失某事,这是因为当我修改数据时调用了 getView()

I can't write into the EditText, it disappears when i try to write something, its because the getView() is called when i modify the data

我需要从 SQLite & 加载一些数据在 ListView 或 Grid 中列出它.接下来是提供内联编辑功能,即用户也可以在该 ListView OR 网格中编辑数据.

I need to load some data from SQLite & list it in a ListView or Grid. The next thing is to provide the inline editing functionality, i.e the user can edit the data also within that ListView OR grid.

目前我正在为此使用 ListView.我所做的是为行项目定义了布局,下面提供了示例 xml:

Currently i am using the ListView for this purpose. What i have done is that i have defined layout for the row item, the sample xml is provide below:

rowitem.xml

<TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightSum="1"> <TextView android:text="" android:id="@+id/txtQuestionId" android:layout_width="100dp" android:layout_height="50dp" android:clickable="true" android:padding="5dip" android:gravity="left" android:background="@android:color/transparent"/> <EditText android:text="" android:id="@+id/txtQuestion" android:layout_width="400dp" android:layout_height="50dp" android:clickable="true" android:padding="3dip" android:gravity="left" /> <TextView android:text="" android:id="@+id/txtStandard" android:layout_width="200dp" android:layout_height="50dp" android:padding="5dip" android:gravity="left"/> <RadioGroup android:id="@+id/rdbStatus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="1"> <RadioButton android:id="@+id/rbSAT" android:layout_width="wrap_content" android:text="SAT" android:layout_height="wrap_content" android:onClick="onStatusClicked"/> <RadioButton android:id="@+id/rbUNSAT" android:layout_width="wrap_content" android:text="UNSAT" android:layout_height="wrap_content" android:onClick="onStatusClicked"/> <RadioButton android:id="@+id/rbNA" android:layout_width="wrap_content" android:text="NA" android:layout_height="wrap_content" android:onClick="onStatusClicked"/> </RadioGroup> </TableRow> <!-- just draw a red line --> <View android:layout_height="2dip" android:background="#FF0000" /> </TableLayout>

我从 SQLite & 获取数据使用自定义 DataAdapter 类将数据与 ListView 绑定.

I am getting the data from SQLite & using a custom DataAdapter class bind the data with ListView.

我有几个问题:

1- 在 android 中进行内联编辑的最佳做法是什么?

2- 内联编辑 ListView 或 Grid 的最佳选择是什么?

3- 什么是优点 &使用 ListView 进行内联编辑的硬币?

非常感谢.

推荐答案

好吧,这是我的个人意见.. 喜欢就试试..

Ok, Its my personal opinion.. try if you like it..

  • 从数据库中填充列表中的数据.(布局中不需要 EditText).

  • Fill data in your list from database. (No need of EditText in layout).

    使用 Edittext 创建一个对话框.现在,当用户单击 ListItem 时,用当前选定列表行文本视图中的预填充文本打开该对话框.然后允许用户更改它.当用户在对话框上单击确定"时,然后在列表项中修改该 Textview ..

    Make a dialog with Edittext. Now when user click on ListItem open that dialog with pre-populated text from current selected list row textview. Then allow user to change in it. When user click OK on dialog then modify that Textview in list item..

  • 更多推荐

    使用 ListView 进行内联编辑是否可以?

    本文发布于:2023-10-05 07:56:59,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1467332.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:内联   编辑   ListView

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!