OnClick与android:focusableInTouchMode="true"
2017-09-19 15:41
537 查看
也许这是一个老问题,但是遇到了。所以将自己找的解决办法写下来。
程序中有一个button,它设置了android:focusableInTouchMode=”true”,并且也设置了按键onClick方法。那么第一次点击的时候,它将取得焦点,而第二次点击的时候,才执行onClick方法。我所需要的效果是,同时在第一次点击的时候了得焦点,并且执行onClick方法。
程序中有一个button,它设置了android:focusableInTouchMode=”true”,并且也设置了按键onClick方法。那么第一次点击的时候,它将取得焦点,而第二次点击的时候,才执行onClick方法。我所需要的效果是,同时在第一次点击的时候了得焦点,并且执行onClick方法。
button.setOnTouchListener(new onTouchListenerImpl()); class onTouchListenerImpl implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP) { v.performClick(); } return false; } };
相关文章推荐
- OnClick与android:focusableInTouchMode="true"
- Android属性 android:focusableInTouchMode
- Android android:focusableInTouchMode
- Android属性 android:focusableInTouchMode
- Android touch mode和focusableInTouchMode分析
- View focusableInTouchMode=true导致第一次点击不响应
- Android属性 android:focusableInTouchMode
- Android touch mode和focusableInTouchMode分析
- Android: 让一个EditText失去焦点,setFocusableInTouchMode与setFocusable 效果不一样
- android focusableInTouchMode属性
- android:focusable和android:focusableInTouchMode的区别
- android中的setFocusable(Boolean T)和setFocusableInTouchMode(Boolean T)的区别
- focusable ,focusableInTouchMode,控件焦点属性;Android 如何让EditText不自动获取焦点
- Android中View的focusableInTouchMode属性对Listview的OnItem点击事件的影响
- View的onclick、focusable、focusableInTouchMode属性详解以及跑马灯的实现
- Android属性 android:focusableInTouchMode
- android中focusable和focusableInTouchMode
- Android属性 android:focusableInTouchMode
- Android 开发中遇到View类的视图属性focusableInTouchMode及与focusable有什么区别?
- android:focusableInTouchMode