EDIT:
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
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.
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>
I am getting the data from SQLite & using a custom DataAdapter class bind the data with ListView.
I have few questions:
1- What are the best practices for inline editing in android?
2- What is the best option for inline Editiing ListView OR Grid?
3- What are pros & coins of using ListView for inline Editing?
Great Thanks.
Ok, Its my personal opinion.. try if you like it..
Fill data in your list from database. (No need of EditText in layout).
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..