Android - 如何在验证后为 google+ 登录按钮设置文本

标签 android text google-plus

我有一个使用 Google+ 登录 服务的 android 示例。当启动应用程序时,Google+ 登录 按钮会出现并带有 Login 字符串。

如何在连接和验证后为 Google+ 登录 按钮设置文本 注销。 帮我解决这个问题。

最佳答案

在 GooglePlus 客户端成功建立连接后,调用 onConnected() 回调。

因此,您需要做的就是在用户登录后立即更改按钮的文本。

@Override
    public void onConnected() {
        //called after successful connection
        setGooglePlusButtonText(signInButton, R.string.googleplus_signout);

    }


protected void setGooglePlusButtonText(SignInButton signInButton, String buttonText) {
    for (int i = 0; i < signInButton.getChildCount(); i++) {
        View v = signInButton.getChildAt(i);
        if (v instanceof TextView) {
            TextView mTextView = (TextView) v;
            mTextView.setText(buttonText);
            return;
        }
    }
}

关于Android - 如何在验证后为 google+ 登录按钮设置文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21037411/

相关文章:

android - 文本未显示在 MapView 叠加层上

android - 通过 Android 应用获取 Google+ 上的个人资料信息

Android - Google+ 登录

php - Android:比较json数据和String

android - "Launch timeout has expired, giving up wake lock"上的监听器或通知

java - 从数据库 SQlite 中的 jTable 存储值进行不区分大小写的搜索(IDE : netbeans)

ios - 如何从 iOS 中的 Google Developers Console 获取客户端密码?

android - 将多个项目和单个项目导入到 Android Studio

android - 不允许 adb shell 操作

SQL 子字符串 - 删除最后一个字符