简体   繁体   English

android按钮发件人双击

[英]android button sender double click

i am new to android programming, i am trying to allow the blind user to add contact number, when he clicks one click he will listen to the key sound and in double clicks the pressed key is appended, when he clicks one click in key and then double click on another key it will append the previous number key not last key. 我是android编程的新手,我试图允许盲人用户添加联系电话,当他单击一次单击时,他会听到按键声音,并在双击中附加所按下的键,当他单击一次单击时,然后双击另一个键,它将附加上一个数字键而不是最后一个键。 my problem it will append last key not previous one. 我的问题是它将追加上一个密钥而不是上一个。

here is my code : 这是我的代码:

 public void num_phone(View Sender)
    {
        btn = (Button)Sender;
        long currentTime =System.currentTimeMillis();
        if (currentTime - lastClickTime > DOUBLE_CLICK_TIME_DELTA) 
        {
            b=2;

            f=btn.getText().toString();
            Toast.makeText(MainActivity4.this, ""+f , Toast.LENGTH_SHORT).show();
        }

        else {
        if(isempty)
        {

            name.setText(f);
            isempty=false;

        }
        else if(!btn.getText().toString().equals("Erase"))
        {
            name.append(f);

        }
        else if(btn.getText().toString().equals("Erase"))
        {
            name.setText("");
        }
        }
        //String phoneNum = phone.getText().toString();
        lastClickTime = currentTime;

         detector = new GestureDetector(this, this);
            detector.setOnDoubleTapListener(this);


        //String alphabatic = name.getText().toString();
    }

Maybe you could just attach this double tap listener to a container that is holding those buttons (some sort of layout)? 也许您可以将此双击侦听器附加到装有这些按钮的容器(某种布局)?

You would get single clicks on buttons normally (and storing the information about which button was clicked last) and when user double taps one of the buttons (the whole layout) you would just force the click of the button that you've stored previously (single-clicked). 您通常会在按钮上单击一下(并存储有关最后单击哪个按钮的信息),并且当用户双击其中一个按钮(整个布局)时,您只需强行单击先前存储的按钮即可(单击)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM