Multiple tooltips or multiple styles for the same hint of edittext

How to add another tooltip to the EditText component that will respond as a tooltip, but on the other, as the default tooltip.

For example: the field name is a city, so I would like the main hint in black to be displayed as β€œcity”, and in light blue I would like it to be written out as β€œclick to select city”.

Are there any ready made components or xml attributes for this? Is this the case when I need Java code and implement onfocus and show / hide another TextView that will react as a label?


I got this as strings.xml:

<string name="fld_fullname">
    <![CDATA[
        <font color="#8B8B8B">City</font> <font color="#BABABA">tap to change</font>
    ]]>
</string>

and this is in the Java code:

etCity.setHint(Html.fromHtml(getString(R.string.fld_city)));

Now, how can I take the color from colors.xml? Can I use placeholders or is there a better way? Request best practice ...

+1
1

EditText , ,

myEditView.setHint(Html.fromHtml("city - <font color='blue'>tap to select a city</font>."));

EDIT: string.xml color.xml, :

myEditView.setHint(Html.fromHtml(getString(R.string.hint1)+" <font color='"+getResources().getColor(R.color.hintColor)+"'>"+getString(R.string.hint2)+"</font>."));
+4

Source: https://habr.com/ru/post/1692663/


All Articles