0

I'm just working on an app that is storing multiple strings of data per person, in a string array. I will likely either put the String[] as a variable in a Person class or use HashMaps to store them per person (haven't decided yet but it shouldn't make a big difference for the question). For example for two people, it may look something like:

"John": ["20", "40", "1", "400"]
"Michael": ["11", "3", "09", "98"]

I want the user to be able to edit one of the data of a person graphically. For example, the user will look at a list of people and choose he/she wants to edit the second element in person Michael's array from "3" to "100".

Should I try to use an onClickListener in a ListView to detect which person's name was selected and then dynamically create EditText boxes for each of the elements in the person's array so that the user can click one of the EditText boxes and edit it?

Or is there an easier, more clutter-less way of doing this? I suppose there is no right answer for this but if someone could suggest an efficient and simpler direction to proceed in from their experience, it would help me a lot.

Thank you in advance.

1 Answer 1

1

You can set an OnItemClickListener to the ListView, write a switch-case in the listener for finding the selected item, and a dialog that had it's view from a xml file containing EditTexts you need. Other ways are similar to this. user needs widgets like EditText, spinner, etc. to interact with your App.

Sign up to request clarification or add additional context in comments.

1 Comment

But since I do not know how many elements will be in the array (I'll parse a file to get them, put them in an array, let the user edit the values and then eventually write everything back), would creating EditText boxes work? What if there are dozens of values? Is there a more visually compact way of doing this which wouldn't clutter the screen with 20 different EditTexts?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.