I have a problem in input type attribute, I need a person name to be written in the edit text but when I run the application, the keyboard doesn't changed dynamically and it allows the user to enter any characters in the name field. Here is the code:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name:"/>
<EditText
android:id="#+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
/>
It appears you can only use the input type attribute to limit to numbers. The link below might help you with you question.
https://stackoverflow.com/a/4401227/1157215
Related
I have the following AutoCompleteTextView :
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:textSize="20sp" >
</AutoCompleteTextView>
The input to this AutoCompleteTextView is done via a "Dialer" Layout I've created , thus this AutoCompleteTextView is android:enabled="false" and in order to add the user input on my AutoCompleteTextView I use the following code :
String mText =_searchAutoCompleteTextView.getText().toString()+_dialer_digits[position]; //the digit the user clicked upon
_searchAutoCompleteTextView.setText(mText);
_searchAutoCompleteTextView.performCompletion();
if(_searchAutoCompleteTextView.getText().toString().length()>2 && _searchAutoCompleteTextView.getAdapter().getCount()> 0)
{
_searchAutoCompleteTextView.showDropDown();
}
Every thing is working fine except a weird issue :
Since the input is not done by the device's keyboard and only by my dialer with setText() , if the user clicks alot of digits whihc are longer than the AutoCompleteTextView's size last digit is broken and while continuing to input more digits the AutoCompleteTextView does not scroll left. The weird thing about it is that I've tried to enable it and put some long input from the device's keyboard it works perfectly , long text is not broken and scrolling is happening. Since I cannot use the device's keyboard it must be done via my layout and setText()
Many thanks ahead
EDIT:
here is a screen shot :
You can use append instead of setText to move the cursor to the end.
I'm not sure if this will work but have you tried to put your AutoCompleteTextView in a HorizontalScrollView?
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:textSize="20sp" >
</AutoCompleteTextView>
</HorizontalScrollView>
Can you provide a screen shot so I can better understand the issue you are having?
You need to set Gravity of AutocompleteTextVIew to right:
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:gravity="right"
android:textSize="20sp" >
</AutoCompleteTextView>
I need a number keyboard on a PIN EditText. I tried using
android:inputType="number|textPassword"
This brings up the number keypad, but the characters are not password chars.
How to get a number keypad that shows password chars in EditText view?
The app runs on 2.2 and above.
You should have a look here:
Edittext set for password with phone number input? (android)
It states that
android:password is deprecated, but is the only way because android:inputType="phone|textPassword" is ignored ...
<EditText
android:id="#+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:password="true"
android:inputType="phone"
/>
In my styles.xml, these two seem to work for me:
<item name="android:inputType">numberPassword</item>
<item name="android:password">true</item>
This works:
<EditText
android:id="#+id/pinEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:digits="1234567890"
android:inputType="textPassword"
android:maxLength="4" >
<requestFocus />
</EditText>
If digits will work for you.
EDIT: Ah, I see, it doesn't bring up the number keypad....back to the drawing board.
Use : "numberSigned|numberPassword"
I have a very simple layout made of TextViews and disabled EditTexts put by turns. Most of the EditTexts contain plain text but I have two special fields and I have problem with them:
Phone number: as an autoLink type I set "phone". The problem is that a phone number is invisible until I click inside the edit:
<EditText
android:id="#+id/service_order_contact_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:focusable="false"
android:enabled="false"
android:inputType="phone"
android:gravity="right"
android:autoLink="phone" >
</EditText>
I would like to enable user to click address to open google map. I set an autoLink attribute to "map" but it seems not to work. Do you know how to do it?
<EditText
android:id="#+id/service_order_address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:enabled="false"
android:focusable="false"
android:singleLine="false"
android:lines="2"
android:inputType="textPostalAddress|textMultiLine"
android:autoLink="map"
android:gravity="right" >
</EditText>
I don't think EditText and autoLink are designed to work together... Think about this scenario when the user is editing a value:
The user enters a phone number, say: 5557891234
The user made a mistake and clicks in the middle of the EditText to be able to change a digit in the middle of the phone number...
Instead of being allowed to edit the number, the link action takes them to the dialer with the incorrect phone number.
I'm trying to define an EditText but this warning is shown:
This text field does not specify an inputType or a hint.
The code in main.xml is:
<EditText android:id="#+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/textTest" />
How can I fix it?
You could add a hint :
android:hint="This will appear to the user if he didn't enter something yet in the EditText"
and a inputType so you could present to the user a better suited soft keyboard for the text he is suposed to enter in the EditText:
android:inputType="number"
will present a soft keyboard with only numbers and various signs.
Those are just warnings, you could ignore them but is better for the user to implement them.
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
>
I think You should add input type.......
This is a known issue. Sometimes it doest work with changing to:
android:inputType="text"
I got it to work by setting:
android:inputType="textNoSuggestions"
Hope this helps
Above all are the solutions but before that you should understand what does that warnig mean.
Hint:- Hint is the text shown to user before writing anything over.
For eg. if you are putting a edittext where you want user to add his
name then you can write
<Edittext
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Enter Name"/>
Input Type:- This is the xml tag that is to be used within edittext to let edittext to follow that particular restriction. if you are giving inputtype:number then user would be able to enter only numbers. There are several input type fields are there for that you can refer official developer site.
Whenever a word is typed in the EditText box, I always see an underline under the word being typed. But when I press a space after that word I no longer see the underline.
My reqirement is to remove that underline when the user is typing the message.
Added is the screenshot and we see that Smith is underlined. But I don't want this to happen.
Below is the xml that I use for the AlertDialog box.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/name_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="#string/alert_dialog_name"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/username_edit"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:inputType="textPersonName"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
android:inputType="textNoSuggestions"
There is a function that removes any composing state. I think if you call it after every time a user types, you will not see the underline. I use it after the user finishes typing, to get the drawing cache of the entire textView (which I need without underline). It's
someTextView.clearComposingText();
You don't have to use any logic to remove the underlines -- just call getText().toString() when you want to use the value. It won't include special formatting or anything.
accepted answer is not given solution, and some other user given answer but no one given full anser, so that's why i write here working solution.
If you want to remove underline then just add below code.
XML
android:inputType="textNoSuggestions"
Java
EditText ed;
ed = findViewById(yourId);
ed.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
If you want to set more than one input type then,
ed.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
May be above information is helpful to others.
The best solution for this is to add on your EditText:
android:inputType="textMultiLine|textVisiblePassword"
Use this from your class, if EditText view is dynamic (created from class file):
EditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
OR include android:inputType="textNoSuggestions" with your EditText in XML.
Read this if you want to keep emojis and textNoSuggestions doesn't work for you.
textNoSuggestions does not work in every keyboard.
inputType="textVisiblePassword" works but it removes emoji's from most keyboards.
I found that setting inputType="textUri" works and keeps the ability to add emojis.
try:
android:inputType= InputTypes.TextVariationVisiblePassword;
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#null"
android:imeOptions="actionDone"
android:inputType="textNoSuggestions"
android:maxLines="1"
/>