Android: tooltip does not disappear onFocus with EditText

I'm on Android 3+ and I'm trying to add tooltips to my text editing widgets. I tried to add a hint to the layout as follows:

<EditText android:id="@+id/bar_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="text" android:hint="@string/bar_name_hint" android:imeOptions="actionNext" /> 

But when I focus on the text box, it writes over the tooltip, and the tooltip does not disappear.

Hint Issue http://desmond.imageshack.us/Himg580/scaled.php?server=580&filename=barhintprob.png&res=crop

I found documentation on adding an onFocus listener in EditText, but I would like to avoid this programmatically. The post below also mentioned the use of selectors, but I cannot find documentation on how to do this.

Android EditText Hint

So what is the best way to handle this?

+1
android android-edittext
source share
2 answers

For some reason, I had an activity and fragment setting set twice. About onCreate Activities:

 protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.edit_consumption); 

and on the onCreateView snippet:

 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.edit_consumption, null); 

So, I had 2 layers of layout. I needed to remove this layout from Activity onCreate to fix the problem. You may have the same problem.

+3
source share

You can do it pragmatically

 EditText name = (EditText)findViewById(R.id.bar_name); name.setHint = "user name" 

And remove the text hint in XML

+1
source share

All Articles