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);
}
}); 展开
1个回答
展开全部
布局是什么情况?是点击哪个按钮导致的触发了两次点击事件?
如果是点击 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试试)
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询