How show default keyboard number in Edittext? - android

I want to input EditText som characters:
android:digits="1234567890-_##."
If I don't set inputType keyboard input Text is default.
I want show number keyboard show default.
But:
If in EditText design ,i set:
android:inputType="number"
or
android:inputType="phone"
EditText don't show key (#,_)
How show default keyboard number (allow input digits="1234567890-_##.") in Edittext?

Use this :
<EditText
android:id="#+id/ed1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:inputType="number"
android:digits="1234567890-_##."/>
It works for me and allow me to insert this characters "1234567890-_##." only.
Hope this will help you.
Thanks.

Related

android EditText Switches the keyboard on focus

Android: I set editText Input Type as Number but when focus comes first time it opens alphanumeric keyboard then on second time it opens Numeric Keyboard
Try to set xml in edittext input type like this way..
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
/>

Can I use numberPassword input type and still see the input?

Can I use numberPassword as input type and still see the input?
My goal is to have a 0-9 keyboard with as few as possible other keys (that's why I prefered numberPassword over phone), but the user should still be able to see what he just typed.
This is what I have, but right now the passwords are hidden behind asterisks.
android:digits="1234567890"
android:inputType="numberPassword"
Note: I also tried setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD), which made the input visible, but changed the keyboard from numbers-only to a regular keyboard. I need they keyboard to display numbers-only though.
In Java, just do this:
edittext.setTransformationMethod(PasswordTransformationMethod.getInstance());
If you wanted to hide the password later on, you would just do this:
editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
This did the job:
uEditText = (EditText) findViewById(R.id.editText);
uEditText.setTransformationMethod(null);
There are different ways you can solve this problem
You can use use TextInputEditText with TextInputLayout like below
<android.support.design.widget.TextInputLayout
android:id="#+id/etPasswordLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
android:layout_marginBottom="#dimen/login_spacing_bottom">
<android.support.design.widget.TextInputEditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/fragment_login_password_hint"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
With passwordToggleEnabled, you can toggle between asterisk and password values
You can use the Transformation class to toggle password asterisk and value like below
edittextObject.setTransformationMethod(PasswordTransformationMethod.getInstance());
You can create a custom keyboard with the values you want to display in your keyboard. You can see how to achieve this in this tutorial I wrote about custom keyboard

How to make Android EditText expand vertically when full

I have this EditText
<EditText
android:layout_width="match_parent"
android:layout_height="72dp"
android:hint="#string/write_message"
android:textColorHint="#color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:inputType="textImeMultiLine"
android:id="#+id/message_input"
android:layout_gravity="center_horizontal"
android:backgroundTint="#color/primary_color"/>
When the box is filled up with user inputted text, it scrolls to the right to make room for more text, I do not like this behavior, and would prefer it if the EditText box expanded upwards when it needs more room? Is there a way to do this? Thanks.
Yes, this actually involves two things:
Making the EditText accept multi-line input.
Having its height grow as more text lines are added.
Therefore, to achieve this, you need to set up:
android:inputType="textMultiLine"
android:layout_height="wrap_content"
(Be mindful of the difference between textMultiLine and textImeMultiLine).
The full XML snippet would be:
<EditText
android:layout_width="match_parent"
android:inputType="textMultiLine"
android:layout_height="wrap_content"
android:hint="#string/write_message"
android:textColorHint="#color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:id="#+id/message_input"
android:layout_gravity="center_horizontal"
android:backgroundTint="#color/primary_color"/>
Use both flags: textMultiLine will wrap your input, and textImeMultiLine will provide a break-line key in your keyboard.
<EditText
...
android:layout_height="wrap_content"
android:inputType="textImeMultiLine|textMultiLine"
... />
In my case I have multiline text, but it showed one line and a keyboard:
Though I have already set android:inputType="textCapSentences|textAutoCorrect|textMultiLine", it didn't help. Then I understood that when the keyboard appears in DialogFragment, it collapses the EditText. See DialogFragment and force to show keyboard to show keyboard when DialogFragment shows.
Then I added a short delay (100-300 ms) before showing the keyboard. Now I have:
In AndroidManifest I set android:windowSoftInputMode="adjustResize" for current activity.

How to disable letters in keyboard (leave only digits)?

I'm developing Android application, and I need to disable letters for user's keyboard in order to allow user to input only digits in EditText. Please, tell me, is it possible?
add android:inputType="number" to the EditText in the layout xml.
More information on inputType's can be found at http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType
You can also go further and do something like:
<EditText
android:inputType="number"
android:digits="0123456789"
/>
EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
OR
Using XML
android:inputType="number"

Android: How to implement numeric keypad?

I have an edit text with a background image. When i click on the edit text i should enter numericals.
So, I should dispaly a numeric keypad. I did this by android: inputtype = "Phone" method. But iam not getting numeric keypad. Please help me>?
for this You need to set the EditText's Input type property to number .
android:inputType="number"
you have two solutions for that
the 1st one is to do it in the layout like that android:inputType=""... see below lastline:
<EditText android:id="#+id/getLat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:editable="true"
android:singleLine="true"
android:layout_weight="1"
android:inputType="numberDecimal"
/>
use this..
editview.setInputType(InputType.TYPE_CLASS_NUMBER);
Best
V.k

Categories

Resources