GPGVM
GPGVM

Reputation: 5619

EditText hint not displaying

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

Upvotes: 1

Views: 7251

Answers (2)

AnDx
AnDx

Reputation: 824

  <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" />

Upvotes: 4

Jared Burrows
Jared Burrows

Reputation: 55545

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,

Upvotes: 5

Related Questions