Change text of Google Plus SignInButton – Android

Home / Android / Change text of Google Plus SignInButton – Android

In an application which allows users to sign up and then use it, have a form containing a list of information to be filled by user. For this purpose its easy to integrate some social networking website and get user signed up with just one or two clicks.
Google provides a very easy option to Login using Google and use that information to sign up users.
Implementation of the same requires some adjustment(s) as per UI and look-and-feel of the application. In order to change the text of Google Plus SignInButton use following method




/**
 * Call this method to change text of SignInButton.
 * 
 * @param signInButton
 *            instance of Google plus SignInButton
 * @param buttonText
 *            new text of the button
 */
protected void setGooglePlusButtonText(SignInButton signInButton, String buttonText) {
	// Search all the views inside SignInButton for TextView
	for (int i = 0; i < signInButton.getChildCount(); i++) {
		View v = signInButton.getChildAt(i);

		// if the view is instance of TextView then change the text SignInButton
		if (v instanceof TextView) {
			TextView tv = (TextView) v;
			tv.setText(buttonText);
			return;
		}
	}
}