My question is quite short and simple but I'm unable to find a solution. I wan to make my EditText looks like this form:
So, every time the user input a char (android:inputType="numberDecimal"), it goes to the next box. (Just display the char into next box no need to display the cursor). It would be nice if this could be done using a single EditBox.
I have no other idea than making 5 liniar EditText controls and add TextWatcher to every one of it forcing it to jump (focus) to the next one. But this seems a less elegant solution and more complex.
Has anyone any other ideea?
Why reinvent the wheel everytime. I guess this has exactly what you want.
just checkout here https://github.com/Philio/PinEntryView as you required "Just display the char into next box no need to display the cursor".
Related
I am looking to achieve the functionality of an AutocompleteTextView but slightly different. Instead of getting a drop-down list with suggestions i want it to complete the sentence for me.
For example: i type abc and i get completed, with the rest of the text in grey: abc1#etc.etc and then click a button to keep this text or keep writing to filter this even further.
Do you think is is achievable somehow?
I have looked my problem up so far but all the answers i found involved a drop-down list, perhaps i haven't looked deep enough.
Why don't you try to implement a custom view?
Basically, you need to the same things that the AutoCompleteTextView does but instead of displaying N elements into the drop down list you have to add the first option to your EditText.
Have a look at:
TextWatcher in order to see how detect the user input and progress
You can then play with indexes and spannables in order to keep track of the data input by the user and the data that you are suggesting.
One thing that I don't like about this idea is the fact that if you have got:
Germans
Germany
...
You need to type a lot of letters without the possibility to choose something different from the solution that you are providing.
use below example ... i think help you...
http://teamandroid4u.blogspot.in/2012/06/autocompletetextview-example.html
So I'm new to Android development and I'm currently figuring out TextWatcher.
What I'm attempting to do is attach my TextWatcher listener to an EditText widget and after the user has put in some text, say "Hello" and he highlights "llo" and types in r, I display the change in a TextView widget. For the above example it will display "llo --> r".
Now from what I've read and tried, since the textchangelistener is called every time the user types in something, my code ended up crashing when I ran it on my phone.
Is there a way to call the listener only when the highlighted text is changed so as to avoid calling it every time I'm just typing something in the EditText widget? I hope my question makes sense, I've tried looking around before posting here but I couldn't find anything.
Not looking for code, just some pointers so I can figure out how to do this.
Thanks!
Your best bet would be to use a OnEditorActionListener instead of a textwatcher which I didnt know existed until now. It gets called when there is a change to a textview, and since edit text is a textview than it will work perfectly.
Heres some info on the listener
Btw welcome to the android platform, I think you'll find that it is a rich language and definitely worth learning. If you really want some pointers your main point of reference should be this link which has many guidelines and pointers in the develop tab. Good luck
I am trying to create my own Phone Dialer from scratch in Eclipse Android, I did a simple phone layout in the XML with numbers 0-9 and some Buttons/ImageButtons.
Basically I put some Buttons and ImageButtons and I understand that I need call setOnClickListener() on them in the Java code. Something like:
Button no1 = (Button) findViewById(R.id.button1);
no1.setOnClickListener(new View.OnClickListener()
I did an <EditText on top of the numbers (Buttons and ImageButtons) to display the numbers. But nothing come out when I click. I am not sure what I miss out which cause this problem.
I also did a "settings" button in the same XML file, which upon clicking on the button, a toast will pop out which have a couple of clickable icons. I am not too sure on how to do it. I did read some tutorials but mine seems to be not quite right.
hopefully if the above-mentioned points can be rectified, I hope I can try to make the SMS characters to be Unicode, which can limit to lets say 50 characters etc.. but that's still far-fetched for me though. I'll do this in the later part.
I did a Google research but I don't quite get the correct info as its just bits and pieces here and there...
Actually I want to create this customized phone dialer as I intent to install it in my Mum's 2.1 Froyo phone.
Can anyone advise me please? Is there a sample code where I can check what I went wrong?
Have your class implement OnClickListener and make a switch(arg0.getId()) and a case for each number pressed.
Every time you press a number have an EditText receive that number and then when you press the call button have it call the numbers in that EditText.
In that amount of time, the application may still have some flaws in it. But you are on the right track. I would have your class xxx.java extend View.OnClickListener, then you can add your class as the listener for each button, e.g. no1.setOnClickListener(this);. Use a switch statement to figure out the phone number and make the call.
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.
I am looking around for a number picker in a 10-key style, ideally as a dialog... but called as an activity is fine too. I want to offer the user an interface that is a little more directed toward entering $ for an invoice amount field. I have seen adjustments to the date and time pickers but they looked awkward for this application. I have also seem someone call the built-in calculator, which would be fine, but I don't know how they were capturing a returned value (if they were). Any ideas? Yes, I can fall back to a regular edit field and the standard android keyboard... I was just hoping for something a little more slick. Thanks!
Have you tried setting the attribute android:numeric on the TextView?
TextView documentation