0

I have an EditText which has a hint field saying "Please enter a number". The IME keyboard that I want is that of type number ie. only numbers are allowed!

The problem is if I use the following in the xml layout :

<EditText>
...
android:inputType="number"
android:hint="Please Enter a 10 digit number"
</EditText>

the hint will not be displayed as only numbers are allowed in the EditText.

How to implement a solution that has both : 1. A hint in words/string 2. Input allowed type(IME keyboard) of type number ?

EDIT

Yes, I am using gravity and singleLine attributes and by seeing the comments I guess its because of a known bug in the SDK. I was testing it on 2.3 ver phone.

Vikas Singh
  • 1,781
  • 7
  • 27
  • 54
  • 1
    Is [this](http://stackoverflow.com/q/4945311/645270) (or [this](http://stackoverflow.com/q/8156924/645270)) your problem? (Bug with gravity and hints) – keyser May 28 '12 at 09:04

1 Answers1

2

Check the syntax. It works for both..

 <EditText android:id="@+id/ed"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:inputType="number"
     android:hint="Please Enter a 10 digit number"/>
swathi
  • 673
  • 1
  • 5
  • 7