1

Being new to Android Development (c# OOP dev 10+) I ran into a slight snag (2.3.3) I don't know how to address. I have an <EditText.../> that has two parameters that cancel each other out.

What I mean is that as an Android user I really appreciate when people use tags such as android:inputType="numberDecimal" for an input field where they expect numbers. This saves me from having to flip from ABC to 123 keyboard while trying to complete a field. However the problem comes in when trying to use the android:hint="Hint Text". The hint text won't display if the field has been determined to be a numeric as defined by the android:inputtype.

So I was looking for input on how best to resolve this problem. My thoughts are have a label above the input field...this would standout as the rest of the app uses hint's. I could forgo a hint but not really a good idea as the user would be lost as to what info goes in the field. My third and best thought is to define the inputtype as text then handle the onFocus event and switch it to numeric.

Any other suggestions welcome. JB

Padma Kumar
  • 19,893
  • 17
  • 73
  • 130
GPGVM
  • 5,515
  • 10
  • 56
  • 97

2 Answers2

5

You did not provide any code to make this easier, so here is my answer based off some quick reading and research for I have used "android:hint" many times myself:

Here I believe your question has already been solved before, adding certain layouts to the element "EditText" such as "android:gravity="center_horizontal" may cause your problem:

How to add hint into EditText with inputType="numberDecimal"?

Try removing that and wrap it in a layout that uses "android:gravity="center_horizontal" and put the "EditText" element inside.

Working example on StackOverflow:

Rows don't render properly in Android Layout. Buttons seem to be the problem

Doing a quick Google search here are some examples where people have gotten it to work:

http://technicalmumbojumbo.wordpress.com/2011/11/18/android-tutorial-part-calculator-app-application-example/

http://android10.org/index.php/articlesother/203-unit-testing-with-the-junit-testing-framework

http://www.bogotobogo.com/Android/androidAppsMortgageCalculator.php

Once again, you didn't post a code snippet of the XML you are using, so this is my best guess, just trying to help!

Regards,

Community
  • 1
  • 1
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
  • Well...not sure the exact bug we are dealing with here...if any. I saw the article on having a gravity defined but leaving the gravity in and changing the inputtype to text it works so in my mind it was not the gravity bug. However doing as you suggest it does work???? So I have added xml post and screenshots of each config and the results. – GPGVM Mar 27 '12 at 20:47
  • Hey, everyone has different problems depending on the issue. The most important thing is that we can work together to fix these bugs. So, as long as yours is now working, everything is good :) – Jared Burrows Mar 27 '12 at 22:21
4
  <EditText
  android:id="@+id/edt_id"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_weight="0.5"
  android:gravity="center_horizontal"
  android:inputType="number"
  android:ellipsize="start"
  android:hint="Enter your Number" />
AnDx
  • 824
  • 8
  • 11