我创建了一个 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;
}
上一篇:x86和x64 System.Data.SQLite问题问题、System、SQLite、Data
下一篇:SQLiteDiskIOException:错误code 10:磁盘I / O错误错误、磁盘、SQLiteDiskIOException、code