Handling click on EditText's rightDrawable image
I'm implementing a custom search bar in my Android application. This s开发者_StackOverflowearch bar is just an EditText with a magnifier set to leftDrawable property. My problem is that I don't know how to get noticed when the user clicks the magnifier. Is there any listener for doing this? Am I using the recommended approach to implement this search bar? I know I could use an EditText and an ImageButton on its right side, but I want the magnifier to be inside the EditText.
Is there any listener for doing this?
Not specifically for that image.
Am I using the recommended approach to implement this search bar?
I am not aware that there are recommendations for implementing a search bar. It is not the way Google elected to implement a clickable button for their search bar, which has the button to the right of the field.
You may be able to have the desired effect by:
- Putting the
EditText
in aRelativeLayout
- Adding a transparent
View
as a later child of theEditText
, sized to match the size of your image - Using margins to have the transparent
View
be over top of your image - Setting an
OnClickListener
on the transparentView
精彩评论