onTouchListener警告:onTouch应该调用查看#performClick点击被检测到时 [英] onTouchListener warning: onTouch should call View#performClick when a click is detected
本文介绍了onTouchListener警告:onTouch应该调用查看#performClick点击被检测到时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个 onTouchListener
。不幸的是onTouch()方法抛出
我一个警告:
COM /计算器/ activitys /计算器$ 1号onTouch应该调用查看#performClick点击时检测
这是什么意思?我还没有发现有关此警告的任何信息。这里是全code:
的LinearLayout llCalculatorContent =(的LinearLayout)fragmentView.findViewById(R.id.calculator_content);
llCalculatorContent.setOnTouchListener(新View.OnTouchListener(){
@覆盖
公共布尔onTouch(视图V,MotionEvent事件){
Tools.hideKeyboard(getActivity(),getView());
。getView()clearFocus();
返回false;
}
});
解决方案
在这里你去:
公共布尔onTouch(视图V,MotionEvent事件){
开关(event.getAction()){
案例MotionEvent.ACTION_DOWN:
//一些code ....
打破;
案例MotionEvent.ACTION_UP:
v.performClick();
打破;
默认:
打破;
}
返回true;
}
I have created a onTouchListener
. Unfortunately onTouch() method throws
me a warning:
com/calculator/activitys/Calculator$1#onTouch should call View#performClick when a click is detected
What does it means? I have not found any information about this warn. Here is the full code:
LinearLayout llCalculatorContent = (LinearLayout) fragmentView.findViewById(R.id.calculator_content);
llCalculatorContent.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Tools.hideKeyboard(getActivity(), getView());
getView().clearFocus();
return false;
}
});
解决方案
Here you go:
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
//some code....
break;
case MotionEvent.ACTION_UP:
v.performClick();
break;
default:
break;
}
return true;
}
这篇关于onTouchListener警告:onTouch应该调用查看#performClick点击被检测到时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文