Android - how to set text for google+ signin button after authenticated

android, google-plus, text

Solution

After successful connection has been established by the GooglePlus client, the `onConnected()` callback is invoked.

So, all you need to do is change the text of the Button as soon as the user has been logged in.

@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;
        }
    }
}

Problem

I have an android example using `Google+ signin` service. When start app, `Google+ signin` button appear with `Login` string. How to set text `Logout` for `Google+ signin` button after connected and authenticated. Help me this issue.

Original source