How to remove Android auto-suggest underlining in EditText? - android

I'm using an EditText to write some text. Android's auto-suggest underlines the word, until we hit space. Now, if I enter the word without the space, the resulting text has an underline. It's because I use Html.toHtml(view.getText()).
Now, there are a few answers I'll be expecting such as disabling auto-suggestion or using view.getText().toString(), but I need them both. I need the auto-suggestion feature as well as the formatting of the text. An example which solves this problem is the Gmail app. You can write whatever you want in the EditText box and it sends the email without the words being underlined.

Use this just before you getText(). This is the most straightforward and the official way.
edittext.clearComposingText();

Do it like this
android:inputType="text|textNoSuggestions"

I just came up with a solution for this. After submitting the text, just hide the keyboard, and the text underline goes away.

Related

AutoFill EditText Android

I'm trying to create a search bar like.
I have to use a particular autofill, infact I can't use a dropdowns menu.
For example if I write Noce the edittext will have to suggest Nocera in the same editText, like this.
but if the user write something else the pointer have to the end of the typed text (in this case Noce) and the hint have to disappear.
Is there some library that allows me this?
Thanks for the help.
There's this library that will fulfill some of your requirement called Auto Fill EditText
Finally I have solved this using two EditText in the same position. The first one is a normal editable EditText, the second one is not editable from the user but is used to show the hints programmatically.

Android EditText inputType textShortMessage

What is the purpose of inputType textShortMessage? How will this affect my application? Do certain keyboards, Android versions or applications treat this specially, or differently from just type text?
Not that much difference between text and textShortMessage. While developing the Android Source, google developers felt to create two different class for two different cases. textShortMessage and textLongMessage both inherits the behaviour of text with some different attributes.
There could be so many types of input for a EditText. Android Developer made it easier for us to define the behaviour of a specific EditText.
textShortMessage is for: Variation of TYPE_CLASS_TEXT: entering a short, possibly informal message such as an instant message or a text message.
It means when we use textShortMessage as input type the EditText will open the alphabetic keyboard but the EditText will not be Expanded. If you change it to textLongMessage the EditText will be expanded for multiline text input.
SOURCE: http://developer.android.com/reference/android/text/InputType.html
One difference :
android:inputType="textShortMessage|textMultiLine"
Will give you the smiley button in preference to the enter key.
android:inputType="textMultiLine"
Will give you the "enter" key again.

Is there an industry standard to have the text of a button in capital or small letters for Android?

This may be a mundane question but I wanted to confirm if displaying the text of a button in capitals (like 'OK' or 'REGISTER') is acceptable or should it be in regular text (like 'Ok' or 'Register').
Thanks in advance.
P.S
I don't want to be seeminlgly shout at people using caps in buttons :)
In the Android Design site, you can see some examples of text under Writing Style which have just the first letter capitalized. "OK" is a bit of a special case though as it's an abbreviation of sorts, so I'd leave that with both letters capitalized.
The Android design guide details that and a lot more in the writing style page. Do not use all caps...
There's no standard, at least for buttons and labels it seems to be more of a "design choice". In ICS some of the text (e.g. preference and tab labels) are shown all in CAPS. Interestingly enough, there's a setting for textviews to accomplish that: android:textAllCaps. See this. If it's a block of text of course, don't do it.
Sure. You can use the Java String function toUpperCase() or toLowerCase()

EditText with non-selectable grayed out prefix

I'm looking for a way to have a grayed out text as prefix in an EditText. This text should be not selectable.
It's a bit like the To field when you're composing a message with Gmail. The only (visual) difference is that this text disappears when you start typing.
Is there any trick to achieve this in Android?
Thanks!
You can use an image of the part "EUR 2500". this you can display in your editbox without affecting the rest of the part. Follow the code:
Drawable editTextDrawable = context.getResources().getDrawable(imageId);
editTextDrawable.setBounds(0, 0, editTextDrawable.getIntrinsicWidth(),
editTextDrawable.getIntrinsicHeight());
The drawable can be used inside the edittext as follows:
editTxtItemName.setCompoundDrawables(,
ListViewConstants.editTextDrawable, null, null, null);
As an ultimate solution, you can rewrite the full EditText class by extending it and modifying it in a way that it has a custom Background set by you, and a predefined padding set by you.
Put the EUR as the background, positioning it in the left side, and then give the starting padding of the EditText in such a way that the text the user types, starts right after the EUR text.
This maybe regarded as an overkill or a poor-man's solution to this problem, but still its the ultimate option. Not the smartest one perhaps, and I also don't know if its gonna work for sure :P
All the best!

EditText and MultiAutoCompleteTextView suggestions

I'm using a MultiAutoCompleteTextView in my app to show various suggestions.
I noticed that MultiAutoCompleteTextView doesn't support the regular android suggerstion that come defaultly with an EditText (the strip of suggestions that pops above the soft keyboard.
Is there a way of showing both the regular suggestions, and the ones I want to show in my MultiAutoCompleteTextView?
I found that setting the input types only took effect when I set them with setRawInputType(). I also found out that the only way to use InputType.TYPE_TEXT_FLAG_AUTO_CORRECT was to include
include InputType.TYPE_CLASS_TEXT also. So it would result in something like this:
multiAutoCompleteTextView.setRawInputType(InputType.TYPE_CLASS_TEXT
|InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
|InputType.TYPE_TEXT_FLAG_MULTI_LINE);

Categories

Resources