我有一个包含图标的 EditText
<EditText
android:id="@+id/myedittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@mipmap/microphone"/>
我为EditText
右侧的Drawable
设置了onClickListener
myeditText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_LEFT = 0;
final int DRAWABLE_TOP = 1;
final int DRAWABLE_RIGHT = 2;
final int DRAWABLE_BOTTOM = 3;
if(event.getAction() == MotionEvent.ACTION_UP) {
if(event.getRawX() >= (myeditText.getRight() - myeditText
.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
// your action here
Toast.makeText(getApplicationContext(),
"speak",Toast.LENGTH_SHORT).show();
return true;
}
}
return false;
}
});
当我点击
EditText
右侧的图标时,会显示一个Toast并起作用,但是还会在EditText
上显示粘贴选项。如何在单击右侧图标时删除粘贴选项?