[英]onTouchEvent and onClickListener can't work together on the same page
[英]onTouchEvent works on one page but it doesn't work on another page
我是Android的ontouchevent()
,我尝试使用ontouchevent()
来检测屏幕触摸,我在示例页面之一上工作,但是当我将相同的代码复制粘贴到另一页面上时,它似乎无法正常工作。
我认为这与View
。
有人可以帮我吗
码
public class HelpDesk extends Activity{
@Override
public void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
ImageButton home = (ImageButton)findViewById(R.id.home);
ImageButton exit = (ImageButton)findViewById(R.id.exit);
final Intent homeIntent = new Intent(this,MobNavSys4VisuallyImpaired.class);
home.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
startActivity(homeIntent);
}
});
exit.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
startActivity(homeIntent);
}
});
}
public boolean onTouchEvent(MotionEvent event)
{
System.out.print("touch");
Toast.makeText(this, "hiiiiii", Toast.LENGTH_SHORT).show ();
return true;
}}
`
核实
更改return true;
return super.onTouchEvent(event);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.