Android工作多点触控按钮

Android工作多点触控按钮,第1张

概述嗨,我想创建2按钮,我想要多点触控?我试着做但在互联网上没有例子..所以如果你有一个可以分享或者你能给我意见吗?我的代码是这个但不支持多点触控packagemulti.touch;importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.MotionEvent;import

嗨,我想创建2按钮,我想要多点触控?

我试着做但在互联网上没有例子..

所以如果你有一个可以分享或者你能给我意见吗?
我的代码是这个但不支持多点触控

 package multi.touch; import androID.app.Activity; import androID.os.Bundle; import androID.vIEw.MotionEvent; import androID.vIEw.VIEw; import androID.vIEw.VIEw.OntouchListener; import androID.Widget.absoluteLayout.LayoutParams; import androID.Widget.button; import androID.Widget.TextVIEw; public class baslat extends Activity implements OntouchListener  {  TextVIEw yazi; TextVIEw bir,iki; button buton1,buton2; @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); yazi=(TextVIEw)findVIEwByID(R.ID.textVIEw1); bir=(TextVIEw)findVIEwByID(R.ID.textVIEw2); iki=(TextVIEw)findVIEwByID(R.ID.textVIEw3); buton1=(button)findVIEwByID(R.ID.button1); buton2=(button)findVIEwByID(R.ID.button2); buton2.setontouchListener(this); buton1.setontouchListener(this); } @OverrIDe public boolean ontouchEvent(MotionEvent event) {    yazi.setText(String.valueOf(event.getPointerCount()+"\n\n"));            bir.setText(String.valueOf("Birinci " + (int)event.getX(0)+"\n\n"+(int)event.getY(0)));        iki.setText(String.valueOf("Ikinci"+ (int)event.getX(1)+"\n\n"+(int)event.getY(1)));    //buton2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, (int)event.getX(0), (int)event.getY(0)));      return super.ontouchEvent(event);            } @OverrIDe public boolean ontouch(VIEw v, MotionEvent event) {    button fds=(button)v;            return false; } }

解决方法:

老问题,但是我一直在墙上遇到这个问题,直到我终于遇到了设置

androID:splitMotionEvents="true"

在包含按钮视图的布局视图上,允许按下多个按钮,我发现在sdk演示下载中可用的APIDemos中挖掘

总结

以上是内存溢出为你收集整理的Android工作多点触控按钮全部内容,希望文章能够帮你解决Android工作多点触控按钮所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1102832.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存