0

I am tyring to accomplish a part of my app where the user can input a maximum number of 10 players names but each name will be limited to a maximum of 12 characters. Once the user has inputed each name they will start to appear next to the input box in a kind of listview (not sure if this would be the best way) with a remove button. Also when each name is enterd I need that to have been saved into a string/array as these names will need to been showen in the next Activity.

My question is does anybody have any experience with this or any suggestions as where to start?

Not sure what kind of input method I should be using would a EditText be OK?

 <EditText
    android:id="@+id/userinput"
    android:layout_width="190dp"
    android:layout_height="40dp" >
    <requestFocus />
</EditText>

Also I have been reading around differernt methods such as SoftKeyboard or the InputMethodService class just not sure where to start with this?

1
  • What about using MVVM pattern and binding library to avoid coupling between view and handling logic? Commented Jan 9, 2012 at 15:19

1 Answer 1

4

EditText will be fine. You could either use 12 different EditText boxes, 1 for each player, or you could make just 1 box and clear it every time a name is saved.

Just have a confirm button next to the/each EditText, and write an onClickListener so that when that button is clicked, you take what's in the EditText and add it to the array (clearing the EditText if you need to).

For the remove player button, simply add buttons next to the list, and give each button an onClickListener which removes the corresponding address in the array, remembering that array addresses start at 0.

If you need a little help with some of the code, let me know which part you're stuck on.

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

1 Comment

Great explanation is it possible for us to join a chat?

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.