【发布时间】:2016-07-16 13:31:28
【问题描述】:
我有 EditText 和里面的图标
<EditText
android:id="@+id/myedittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="@mipmap/microphone"/>
我将onClickListener 设置为Drawable 右侧的EditText
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 上显示粘贴选项。
右键单击图标时如何删除粘贴?
【问题讨论】:
-
你解决了吗?