User Input Into Array - android

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?

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.

Related

text entered in EditText does not change into password immediately

the password when entered by user does not change into * immedietly and plain text is displayed for 5 secs or so.I don't want this as my making a custom lock screen otherwise others can see the password entered.
I'm using
android:password="true"
kindly help
As far as I know this is how it is on all mobile platforms, and it's the "normal" way, because of the small, virtual keyboard you may introduce the wrong character. Nevertheless if you really want to modify that you'll have to create you own EditText, which will extend android's EditText.

Best GUI to let the user edit a list of strings in Android?

Suppose, I need the user to be able to input a list of strings somewhere in the settings of the app. Say, it's a list of URLs. The strings are not supposed to have any spaces, commas or semicolons inside.
The easiest thing I thought of so far is to make a big multi-line EditText with a hint to the user "Separate strings by spaces" and each time the user presses OK, use split(" ") to extract the array of strings.
The problem with that simple solution is that sometimes strings are not long enough to fill the whole EditText width, and >1 strings appear visually in 1 line. Sometimes the URLs are too long, so "www." remains on one line, and the rest of the address appears on the next line. It all looks messy and the user looses track where separate URLs start and end in the line.
Another easy solution: a long single-liner where all strings are separated by ; with optional spaces after. VisualStudio uses that in settings, I find it bad as well since you don't see all the strings at once and have to move in this long line a lot (even harder with the clumsy touch screen).
A more expensive solution: a vertically scrollable list of single-line EditTexts, which are generated programmatically each time the settings screen is opened. Would also need a "+" button which creates a new EditText and a "-" button next to each of the existing EditText's.
EDIT: Another idea: show all the strings in a plain ListView with a "+" button in the last row. When you tap "+", it turns into an EditText with 2 buttons to the right: "OK", "Cancel". "OK" would save the newly added string.
If the user taps any of the items in the list, the line turns into an EditText with "OK" and "Delete" button. "OK" saves edits, "Delete" deletes the item. "OK" and "Delete" buttons better should have images instead of words.
Or, well, all strings can be shown in a ListView, and each time the user taps on an item, an additional popup is shown with EditText for editing the string and 3 buttons below: "OK", "Cancel" and "Delete".
Am I thinking along the right lines? Do you know any existing patterns/libraries/solutions which solve this problem efficiently on touch screens?
It would be better, to have only a single editText, where user can set values in list one by one, and can see added values in listView, There may be some provision for a button to save all entered data, onve. See following link once,
http://www.mubasheralam.com/tutorials/android/listview-transcript-mode
IMHO touch screens are not made for extensive writing since the touch keyboards are awful for writing stuff too long or with too much symbols (e.g. programming language or URL). Do not think about touch apps like old desktop apps/systems. Maybe you should rethink your design and try to avoid this data input.
If it's something your app cannot live without, or you simply do want to do it that way anyway:
I think a newline separator is way more clear than a space or a ";" (assuming the URLs cannot contain ";" btw...).
What about one EditText for each URL, generating EditTexts programatically as the previous one is filled.

Android how to get Suggested strings array of the TextEdit

Is there a way to get an array of the suggestions strings which are shown when you typing in EditText? The problem is I have an EditText and in case of user use "Show Suggestions" option the result of the string from this EditText is different in case of user pressed, lets say UI button (this is a Button from the layout), and a return button at the soft keyboard. In first case user gets an exact string but in second - it gets corrected (suggested) string even user do NOT select this suggestion. How to solve this problem? How to get from EditText "suggested" string? Do I need to implement my own IME?
Maybe this can help you ? Hello Auto Complete
Or if you want to write one on your own.. Writing your own autocompleteview
Are you trying to disable suggestions or to modify them?
If you want to disable them completely, check this out:
How to disable displaying "suggestions" on the Soft Keyboard

Android: Virtual Keyboard: the use has no idea what EditText he is filling in

I have a few forms that the user has to fill in and I use EditText to enter the information.
the problem is, when the user uses the virtual keyboard there no information about which field he is filling in.
so its fine when there is only one field but when he has 4 or more he fills in the first one, presses next and he has to remember what was the second field and so on
is there a way to set a title in the EditText so that instead of being just a text zone it has a title to remind the user what he is inputing ?
You can add a hint, which pre-fills the EditText with a useful reminder (in a faded-out colour). This disappears when the user starts typing.
android:hint="Type your name here"
Unfortunately the input method editor bits don't let you do that (though that would be nice). Try setting the attribute android:imeOptions="flagNoExtractUi" on the EditText instances.

Android - Custom calculator?

I am writing a custom calculator Android app. Basically, I have five edittexts, a calculate button and a reset button. I have hooked up the reset button so that onclick of the reset button it sets the value of all five edittexts to "".
How would I go about getting the values of all the edittexts on calculate button click and making an algorithm? Since there are five values, would I need to save each to a sort of temporary cache string?
I am really, really new to this so very plain english is preferable.
Thanks for any reply.
If what you're trying to calculate is a sum, then you should iterate through the Edit Texts (which you can conveniently save in an Array or a Collection... I'd rather go for the Array actually), and, well, add it to the previous value in an auxiliary variable.
I don't get where is the problem. Maybe I'm misunderstanding something. Seeing your current code could help.

Categories

Resources