Android 工作多点触控按钮 [英] Android work multitouch button

查看:30
本文介绍了Android 工作多点触控按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hi i want to create 2 Button and i want to multitouch ??

我尝试过但在互联网上没有示例..

i tryed to do but no example in internet..

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

So if you got one can you share or can you give me opinion ?? my code is this but not support multitouch

 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()+"

"));
            bir.setText(String.valueOf("Birinci "
 + (int)event.getX(0)+"

"+(int)event.getY(0)));
        iki.setText(String.valueOf("Ikinci"+
 (int)event.getX(1)+"

"+(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; }


 }

推荐答案

老问题,但我一直在纠结这个问题,直到我终于遇到了设置

Old question but I was running my head in the wall with this problem until I finally came across just setting

android:splitMotionEvents="true"

在包含按钮视图的布局视图上,允许按下多个按钮,我在 sdk 演示下载中提供的 ApiDemos 中发现了这一点

on the layout view that contains the button views, which allows for multiple buttons to be pressed, which I found digging in the ApiDemos that are available in the sdk demos download

这篇关于Android 工作多点触控按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆