Below is my layout:
<EditText
android:id="@+id/account_et"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawableRight="@drawable/icon_backall"
android:ems="10"
android:hint="@string/str_md_email"
android:inputType="textEmailAddress"
android:padding="10dp" >
</EditText>
I want to show the drawableRight when EditText be focused.
And hide while without focus.
Another one is that I want to set OnClickListener of drawableRight.
How can I do?
Use View.OnFocusChangeListener. Putting drawable to edittext when you catch the focus, then replacing drawable with null would solve the problem.
I hope my sample will help you
this is the class file in which drawable options are performed
the operation you required successfully performed above.....
i would suggest you to add imageView separated from the EditText and align him to be on top of him with align top and align right and that you have full control so you can invisible him and setOnClickListner
Use like belwo