Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

android - Is this is OK to use the ListView for inline editing?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

  2. 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..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...