How to set multiline,firstletter caps and disable suggestions on edittext - android

I have an edittext for reply to email. i want to give three properties for edittext like Multiline, First character caps and disable word suggestions.
I gave like this in xml...
android:inputType="textCapSentences|textVisiblePassword"
I tried in code also... etMessage.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
I am not able to give multiline....how can i achieve this
thanks

I found solution for this problem
Just set the following parameters in xml file..
android:inputType="textCapSentences|textVisiblePassword"
These are for setting first letter of sentence to caps and disable suggestions
and write following code in ur Activity
edittext.setSingleLine(false);

Try setting android:inputType="textMultiLine|textCapSentences|textVisiblePassword". What might be happening is that it is multiline but only one line is currently shown, in which you could say android:minLines="5" or so.

Related

Multiline hint in TextInputLayout

I have a long text which is required to float over edit text as the requirement says. I went through many such question here, but couldn't find the proper answer. How can we make that possible? I have tried using a '\n' with the hint string but it didn't work.
you can add \n without giving any space. example shown below
<string name="hint_manish">Hint first line\nHint second line\nHint third line</string>
The hint takes on the behavior of the Edittext it's related to.
Adding
android:inputType="text|textMultiLine"
will give you multiple line hint.

EditText with automatic return

I have an EditText in my Android app. When I write something on it I don´t have the enter on my Keyboard and when the cursor goes to the final of the line doesn´t jump to the line below automatically. Which are the properties to change this? Thank you so much.
I answer my own question, it works
edittxt.setInputType(EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
edittxt.setMinLines(minLines);
edittxt.setGravity(Gravity.TOP);
edittxt.setVerticalScrollBarEnabled(true);
edittxt.setSingleLine(false);
Write these two lines in edit text xml
android:singleLine="false"
android:inputType="textMultiLine|textAutoCorrect"

how to disable spellcheck Android edittext

I want to remove the underlines from texts inside edittext fields.
How can I do that?
You can do it with following code. Just paste it in layout of EditText.
android:inputType="textNoSuggestions"
In order to get rid of spell checking you have to specify the EditText's InputType in the XML as the following:
android:inputType="textNoSuggestions"
However, if your EditText is multiline and also you need to get rid of spell checking,then you have to specify the EditText's InputType in the XML as the following:
android:inputType="textMultiLine|textNoSuggestions"
Minor addition to Chintan's answer - such (and other) combination is also allowed:
android:inputType="textCapSentences|textNoSuggestions"
Or if you want to just disable the red underline (and the autocorrect dialog), you can override the isSuggestionsEnabled() method on TextView.
This will keep the keyboard autocomplete working.
I just Added a line in for EditText
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
and it worked fine for me.
So I was not able to find out any direct way of doing it. So went ahead with below workaround:
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
As the input type becomes a visible password, even if the spell check is enabled from the device settings, the Red underline won't appear. :)

Creating multiline Edit view in android with coding

I have created an EditText object dynamically but I haven't been able to create a multi-line EditText. I have tried this:
EditText et1 = new EditText(this);
et1.setHint("Enter Your Address");
et1.setSingleLine(false);
et1.setHorizontalScrollBarEnabled(false);
et1.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
et1.setLines(7);
Thanks.
Include this in your code:
et1.setMaxLines(maxlines);
Or you can set the specific height for the edit text.
If you want the text to wrap to the next line, add TYPE_CLASS_TEXT to the MULTI_LINE flag:
textArea.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
It is the line:
et1.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
that is the problem. Take that out.
setMaxLines doesn't matter much unless you want to set a max number of lines. You should also avoid setting the height to something specific. WRAP_CONTENT works great.
Even changing it to:
et1.setInputType(android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE);
forces it to a single line edit, which seems odd.
This doesn't work either:
et1.setInputType(android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
which is really freakin irritating. Seems like an android bug...
You also might want to set the vertical scroll on and gravity so it can scroll up and down and starts in the top left.
et1.setGravity(Gravity.TOP|Gravity.LEFT);
et1.setVerticalScrollBarEnabled(true);
What worked for me is:
et1.setSingleLine(false);
et1.setHorizontalScrollBarEnabled(false);
et1.setVerticalScrollBarEnabled(true);
et1.setMinLines(minLines);

Password singleline how to

I need to programatically set EditText to display text like password and I also need this EditText to be single line.
I know how to make EditText to display text like password:
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
I also know how to display EditText on single line:
editText.setEllipsize(TruncateAt.END);
editText.setSingleLine();
I don't know how to combine these two. When I put these lines of code together, the EditText is not working. Even the software keyboard can't be displayed for it.
Does anyone of you guys know how to solve my problem? Thanks in advance for your answer(s).
I finally did it. For those who have the same problem the correct approach is to combine the two requests but in the different order than I did it before. So you should do:
editText.setEllipsize(TruncateAt.END);
editText.setSingleLine();
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
I hope this will help someone.
To make EditText conceal password characters, add the password attribute to the relevant element in your layout.
http://developer.android.com/reference/android/widget/TextView.html#attr_android:password
It can also be done programmatically
import android.text.InputType;
import android.text.method.PasswordTransformationMethod;
//.....
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
editText.setTransformationMethod(new PasswordTransformationMethod());
In XML file Type
android:singleLine="true"

Categories

Resources