Skip suggestion string value from Android EditText - android

I have an Android EditText with suggestions enabled. My goal is not to disable suggestion (since i'm able to do that), but to skip some string values from them.
For example, suppose that i'd like to skip 'hello' word.
If i write 'he' in the EditText, my suggestions list shouldn't contain 'hello' since it's a string that has to be skipped. Is it possible?
Hope i explained myself, thanks

Related

Disable misspelling flag of specific words in app?

Our company's name always comes up as misspelled (the red underline) when typed into EditText fields in our app. Is there a way I can disable the misspelling flag for a specific word to avoid this nagging feature?
And before someone suggests android:inputType="textNoSuggestions", I would still like spellcheck to be available to that specific field, and only exclude our company name.
I have no idea if it'll work, but you can try putting android.text.style.LocaleSpan over each occurrence of the company name, using Locale.ROOT (which has no language) as the target locale.
(Most of the time you encounter a CharSequence in a text view it can be cast to Spannable. If it can't, just copy its contents into a SpannableStringBuilder.)

how to add smilies/emotions in my edittext for a notes app in android?

can any one know about how to add/insert emotions/smiles to text(which ever i typed in my edit text for my notes). i have little confusion about if i want to add these smiles of type .png in to edit text type of string, is it possible? and also i have to save these input into sqlite database. normally i know to store string data taken from edit text.
but along with that text i want to also add smiles symbols where ever my cursor placed and to be store in sqlite data base. and get it back to read.
so guys any ideas, most welcome!
Try to use java (i.e. android) spannable method to implement smiley (i.e.) images for that. You will surely get it, search in google for "how to add images/smiley with java spannable method in android?" you will get good idea.
Reading your question the first thing I can think of is Mapping each image to a sequence of letters, for example :) is smiley.png etc. Now your database also has these smaller representation However while reading from the database you can convert those special character sequences to appropriate image.
For simplicity in seraching those Strings You can wrap them in some less used characters i.e. [ or { or <.

SoftKeyboard does not allow keyOutputText and keyIcon on same Key

I am trying to modify the SoftKeyboard example (Andriod 3.1 on Moto Xoom) so that I can use an icon on the key and have it output a unicode character when that key is pressed. Specifically I am trying to have it output a beamed eighth note (musical symbol) which is unicode \u266B. Unfortunately I cannot use keyOutputText and keyIcon on the same key in the symbols.xml file which lays out the keys. I need keyIcon because I could not find a way to change the Typeface on the Keyboard Keys to one with that character. I found where I would do it, but its a call to a private method (.setTypeFace) buried in android.jar (KeyboardView if I recall) so I can't.
So I just use an icon to put on the key. This works fine in combination with android:codes, however android:codes will not output my unicode character when I feed it android:codes="\\u266B" which documentation says it should accept. I need android:keyOutputText="\u266B" to get the character to actually output into my EditText. So I can make the key display an icon of my character and the EditText display the character itself, but not the two together. When I try to use the 2 together it compiles and runs just fine, then I hit the shift button on the keyboard to display the symbols and only the numbers 0-9 show up, the rest of the keyboard is just gone. Now error messages or anything, just gone. Nowhere does it say these two things are exclusive that I could find, nor does it make any logical sense for them to be. If this is a bug, I just want to know so I can accept it and stop banging my head against it (a planned fix date would be nice too). If not, how can I get both the key on the keyboard and the EditText box to show my beamed eighth note. I am open to any suggestion or work arounds. Thanks.
Use a HashMap to map the android:codes to your unicode character.
In XML :
<Key android:codes="719" android:keyIcon="#drawable/zo"/> //use your icon and required code here
In java code:
HashMap<String, String> keyCodeMap = new HashMap<String, String>();
keyCodeMap.put("719", ""+'\u0986');
Then, in the onKey(int primaryCode, int[] keyCodes) method get the corresponding character using using following code:
String c = keyCodeMap.get(String.valueOf(primaryCode));
Use the value of c where you need.
Not sure if this is really going to help, since it's for AnySoftKeyboard, but the problem is the same, so maybe the solution is too?
What solved the problem (for me, creating a layout for ASK) was this:
supply both keyIcon and keyOutputText AS WELL as android:codes, but NO keyLabel!
keyLabel gets filled (by ASK?) with the first letter of android:codes, but you still see the image and it outputs multi-letter text.
Hope it helps, might be worth a try in any case, I guess.
(Please note: I just found this out and although I could reproduce it, I can't guarantee if it really was this that solved the problem. I honestly think so, though.)
Instead of using \u266B in android:codes try the int value of the unicode: 0x266B.
Then from onKey you can convert it back to String using:
Character.toString((char)primaryCode)

How to setup my EditText xml in Android

For allow user only can input lower case alphabet and number, how can I setup my EditText in a xml file ?
Sorry, I did not provide clear information. I just want to filter or check user's input.
AFAIK, your question is complicated to do. better get a input from user. then you can convert that string to lowercase using toLowerCase().

How to search and Highlight Text within an EditText

I've searched high and low for something that seems to be a simple task. Forgive me, I am coming to Android from other programming languages and am new to this platform and Java.
What I want to do is create a dialog pop-up where a user enters text to search for and the code would take that text and search for it within all the text in an EditText control and if it's found, highlight it.
I've done this before, for example in VB and it went something similar to this pseudo code:
grab the text from the (EditText) assign it to a string
search the length of that string (character by character) for the substring, if it's found return the position (index) of the substring within the string.
if found, start the (EditText).setSelection highlight beginning on the returned position for the length of
Does this make sense?
I just want to search a EditText for and when found, scroll to it and it'll be highlighted. Maybe there's something in Android/Java equivalent to what I need here?
Any help / pointers would be greatly appreciated
grab the text from the (EditText) assign it to a string
Try the code sample below:
EditText inputUsername = (EditText) findViewById(R.id.manageAccountInputUsername);
inputUsername.getText().toString()
^^ Replace the IDs with the IDs you are using.
After this, you have the standard string methods available. You could also use Regex for a complex search query:
http://developer.android.com/reference/java/lang/String.html
http://developer.android.com/reference/java/util/regex/package-summary.html

Categories

Resources