Is this is OK to use the ListView for inline editing?(可以使用 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 OR 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 中的预填充文本.然后允许用户更改它.当用户在对话框上单击确定时,然后在列表项中修改该 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 进行内联编辑吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:可以使用 ListView 进行内联编辑吗?


基础教程推荐
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01