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"
Related
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. :)
I am creating a dialog box where there is a edit box I want to set the hint of editbox how can I do it.
please help me
thank you
Every EditText is also TextView and the TextView defines a method setHint():
final void setHint(int resid)
Doesn't this work?
EDIT Btw by edit box you mean EditText right?
I am not sure whether this works but might help you,
You could have initialized your Dialog with something like this,
Dialog dialog = null;
And now to Initialize your EditText you should use something like this,
edittext = (EditText) dialog. findViewById(R.id.editbox);
Now use the below method. It should do the trick,
edittext.setHint("Hint");
The same you can provide in the XML file also by adding :
android:hint="Text For Hint"
tag.
For dynamically adding it (in your code and not in XML), Boris & Androi have aldready mentioned it, so wont repeat it.
If you wont be changing once set, then I guess adding in XML is preferred rather than in code.
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.
I have a EditText ans I put an OnEditorActionListener to do something when enter is pressed. My silly question is: how to make the ENTER key green like in Maps?
Here's an answer I found here:
Specifying virtual keyboard type for EditText in XML
Play around with ime options
Thank you guys for the help. I solved it by putting android:imeOptions="actionGo" and android:inputType="textImeMultiLine" in the layout as attributes to the EditText. Both are necessary!
Again thank you!
Haven't tested it but you can try this (section "EditText").
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"