android 怎么避免点击按钮自动触发2次事件 5
现在我的程序里面有一个按钮出现异常,当你点击一下的时候,它自动在下个页面点击别的按钮,现在找不大到问题所在,希望有大神前来解答贴上一部分代码myWebView.setOn...
现在我的程序里面有一个按钮出现异常,当你点击一下的时候,它自动在下个页面点击别的按钮,现在找不大到问题所在,希望有大神前来解答
贴上一部分代码
myWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Log.i(TAG2, "Movtion" + String.valueOf(event.getAction()));
return false;
}
});
btnref.setOnTouchListener(new Button.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
btnref.setImageResource(R.drawable.btnfresh2);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
btnref.setImageResource(R.drawable.btnfresh);
}
return false;
}
});
txmaint.setText("");
maint.setVisibility(View.GONE);
btnmaint.getBackground().setAlpha(0);
btnmaint.setVisibility(View.GONE);
btnmaint.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
splash.setVisibility(View.VISIBLE);
Message msg = new Message();
msg.what = 0;
splashHandler.sendMessage(msg);
}
});
btnref.getBackground().setAlpha(0);
btnref.setVisibility(View.GONE);
btnref.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Message msg = new Message();
msg.what = 0;
splashHandler.sendMessage(msg);
}
}); 展开
贴上一部分代码
myWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Log.i(TAG2, "Movtion" + String.valueOf(event.getAction()));
return false;
}
});
btnref.setOnTouchListener(new Button.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
btnref.setImageResource(R.drawable.btnfresh2);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
btnref.setImageResource(R.drawable.btnfresh);
}
return false;
}
});
txmaint.setText("");
maint.setVisibility(View.GONE);
btnmaint.getBackground().setAlpha(0);
btnmaint.setVisibility(View.GONE);
btnmaint.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
splash.setVisibility(View.VISIBLE);
Message msg = new Message();
msg.what = 0;
splashHandler.sendMessage(msg);
}
});
btnref.getBackground().setAlpha(0);
btnref.setVisibility(View.GONE);
btnref.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Message msg = new Message();
msg.what = 0;
splashHandler.sendMessage(msg);
}
}); 展开
展开全部
布局是什么情况?是点击哪个按钮导致的触发了两次点击事件?
如果是点击 btnref按钮导致间接触发了 webview ontouch事件的话,可以把:
btnref.setOnTouchListener(new Button.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
btnref.setImageResource(R.drawable.btnfresh2);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
btnref.setImageResource(R.drawable.btnfresh);
}
return true;(这返回改成true试试)
}
});
如果是点击 btnref按钮导致间接触发了 webview ontouch事件的话,可以把:
btnref.setOnTouchListener(new Button.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
btnref.setImageResource(R.drawable.btnfresh2);
} else if (event.getAction() == MotionEvent.ACTION_UP) {
btnref.setImageResource(R.drawable.btnfresh);
}
return true;(这返回改成true试试)
}
});
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |