Is there any widget like EditText
which contains a cross button, or is there any property for EditText
by which it is created automatically? I want the cross button to delete whatever text written in EditText
.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Here is complete library with the widget: https://github.com/opprime/EditTextField
To use it you should add the dependency:
In the layout.xml file you can play with the widget settings:
app:clearButtonMode,can has such values: never always whileEditing unlessEditing
app:clearButtonDrawable
Sample in action:
If you are in frame layout or you can create a frame layout I tried another approach....
This is an edit text where I put a cross icon as a right drawable and than UPON it I put a transparent button which clears text.
where, x is:
Android's support libarary has a
SearchView
class that does exactly this. (Not derrived fromEditText
though, so have to use aSearchView.OnQueryTextListener
instead of aTextWatcher
)Use in XML like so:
Use
You can use this snippet with Jaydip answer for more than one button. just call it after getting a reference to the ET and Button Elements. I used vecotr button so you have to change the Button element to ImageButton: