欢迎使用CSDN-markdown编辑器
来源:互联网 发布:淘宝怎么买原味丝袜 编辑:程序博客网 时间:2024/06/03 17:57
public class EditWithDel extends EditText
{
private static final String TAG = EditWithDel.class.getSimpleName();
private Drawable imgInable;
private Drawable imgaBle;
public EditWithDel(Context context)
{
super(context);
init();
}
public EditWithDel(Context context, AttributeSet attrs) { super(context, attrs); init();}public EditWithDel(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init();}private void init() { imgInable = getResources().getDrawable(R.drawable.delete_gray); imgaBle = getResources().getDrawable(R.drawable.delete); addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { setPic(); } }); setPic();}/** * 设置删除图片 */protected void setPic() { if(length() < 1) { setCompoundDrawablesWithIntrinsicBounds(null, null, imgInable, null); } else { setCompoundDrawablesWithIntrinsicBounds(null, null, imgaBle, null); }}@Overridepublic boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP) { int RawX = (int) event.getRawX(); int RawY = (int) event.getRawY(); int x = (int) event.getX(); int y = (int) event.getY(); Log.e(TAG, "RawX ="+RawX+";;RawY ="+RawY); Log.e(TAG, "x ="+x+";;y ="+y); Rect rect = new Rect(); getGlobalVisibleRect(rect); rect.left = rect.right - 50; if(rect.contains(RawX,RawY)) { setText(""); } } return super.onTouchEvent(event);}@Overrideprotected void finalize() throws Throwable { super.finalize();}
}
阅读全文
0 0
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 文章标题
- 内存对齐 & 联合体(共用体)
- Fluent Python笔记
- Android ViewPager禁止滑动、滑动效果
- DirectX11笔记(二)--Direct3D初始化1之基本概念
- 欢迎使用CSDN-markdown编辑器
- vue指令练习demo
- 浅谈线程池及submit()和execute()的区别
- MC9S12XE的模拟EEPROM综述
- DuerOS套件基础环境搭建及语音唤醒初体验
- python 笔记
- Java的继承概述
- cookie 和session 的区别
- 汇编———标志(flag)寄存器