PlusOneButton Android上如何知道用户点击? [英] PlusOneButton on Android how to know if user has clicked?

查看:1385
本文介绍了PlusOneButton Android上如何知道用户点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用我给挖掘在谷歌+1按钮的可能性。

In my Android app I am giving the possibility to tap on a Google +1 button.

这工作正常从developpers源材料以下code(的https: //developers.google.com/+/mobile/android/recommend ):

This works fine with the following code from the developpers source material (https://developers.google.com/+/mobile/android/recommend):

mPlusClient = new PlusClient.Builder(this, this, this)
    .clearScopes()
    .build();  

mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button);

现在我想,当用户点击这个按钮来检测,所以我尝试这样的:

Now I would like to detect when the user taps on this button, so I tried this:

mPlusOneButton.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {                   
        Toast.makeText(this, "Thanks for your +1", Toast.LENGTH_LONG).show();
    }
});

不过,这并不做任何事情,它不会显示敬酒消息。

But it doesn't do anything, it doesn't display the toast message.

作为替代方案,想到具有玩家抽头的两倍的按钮:首先是一个普通按钮对象将使得加一按钮可见,第二个是Plusone精选按钮。但它是一个awckward用户体验

As an alternative, I was thinking of having the player tap twice on the button : first being a regular Button object that would make the plus one button visible, second being the plusone button. but it is an awckward user experience

我如何可以检测用户的敲击这个按钮?

How can I detect user's tap on this button?

推荐答案

另外一个按钮提供了一个侦听器函数来检测按钮的点击。这里是code。

Plus one button provides a listener function to detect button click. Here is the code.

    mPlusOneButton.setOnPlusOneClickListener(new PlusOneButton.OnPlusOneClickListener() {
        @Override
        public void onPlusOneClick(Intent intent) {
            Log.w(tag,"plus one click");

        }
    });

这篇关于PlusOneButton Android上如何知道用户点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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