Android EditText update hints at changing focus using XML only

I read with interest from sunit the answer to this question about updating the EditText tooltip , but could not find any documentation on the use of the method, which I believe he described there: using an element <selector>in the XML layout to dynamically set attributes EditTextat runtime, when the element is focused / not focused.

In my case, I'm more interested in setting up the item android:inputType(because the tooltip disappears for me when the input type is specified), but setting the tooltip will work just as well.

To be clear, I know how to make this change to Java code - I'm trying to figure out if there is a way to specify behavior in XML. Thank!

+1
source share
1 answer

I am afraid that this is not yet possible. <selector>valid only for use in state lists from Drawable and Color resources; it does not work for strings yet.

As for your mention of setting android:inputTypeto make the tooltip disappear, this is actually a known Android bug that will eventually be fixed in later versions, so I would not recommend creating code around this function, as it will break when they will fix this:

http://code.google.com/p/android/issues/detail?id=13895

, , Java, , setHint() OnFocusChangeListener;)

.

+1

All Articles