I am developing an application for Android, and for that I am trying to make a ListView act in such a way, that when a user presses an empty entry, he can start typing text directly into that empty entry, and that when the user touches any other part of the screen, it is saved. Is there a way to do this? I was thinking of using onClick somehow, but I have no concrete approach.
Share
Here is one basic, general approach:
For each row of the ListView, create a layout that has a visible TextView and a EditText with the visibility set to
gone.Use an onClickListener for each row to swap the visibilities of the TextView and EditText (respectively,
goneandvisible) when the row is selected.Track the
activerow for clicks to another row or background.When the
activerow changes, set the value of the EditText to the TextView and return them to their original visible states.