EditText android: tooltip does not disappear onFocus

I am on Android 4+ and I am 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" /> 

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

enter image description here

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?

I wrote this as recommended here by @A - C and @Flexo, because they say “comments that say nothing but me too” are just noise. ”And it’s better to ask the same question again.

Comments like this are very useful as a way to contact the 1st person with a problem ... maybe he already fixed it and can post an answer that will be useful to everyone, but hasn't posted yet because he didn’t think anyone would care .

I’m not going to post answers to questions just to get points, so I can comment ... I have more things to do ... Anyway, this should be available to everyone.

I would not publish this if I had not tried ALL to fix my problem.

+8
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.

+7
source share

use the following code in oncreate ()

 myEditText.setOnFocusListener(new OnFocusListener(){ public void onFocus(){ myEditText.setHint(""); } }); 
0
source share

All Articles