Hide

PlusOneButton

public final class PlusOneButton extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.google.android.gms.plus.PlusOneButton

The +1 button to recommend a URL on Google+. The button fetches +1 data from Google Play services. The +1 attributes can be set via XML, provided the PlusOneButton element has xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" set.

Nested Class Summary

class PlusOneButton.DefaultOnPlusOneClickListener This is an View.OnClickListener that will proxy clicks to an attached PlusOneButton.OnPlusOneClickListener, or default to attempt to start the intent using an Activity context. 
interface PlusOneButton.OnPlusOneClickListener A listener for +1 button clicks. 

Constant Summary

int ANNOTATION_BUBBLE Display the number of users who have +1'd the URL in a graphic next to the button (default).
int ANNOTATION_INLINE Display profile pictures of connected users who have +1'd the URL and a count of users who have +1'd the URL.
int ANNOTATION_NONE Do not render any additional annotations.
int DEFAULT_ACTIVITY_REQUEST_CODE An empty ActivityRequestCode to serve as the default before the code has been assigned.
int SIZE_MEDIUM The medium button size.
int SIZE_SMALL The small button size.
int SIZE_STANDARD The standard button size.
int SIZE_TALL The tall button size.

Inherited Constant Summary

Inherited Field Summary

Public Constructor Summary

Public Method Summary

void
void
initialize(String url, int activityRequestCode)
void
void
setAnnotation(int annotation)
void
setIntent(Intent intent)
void
void
setSize(int size)

Protected Method Summary

static int
static int
getSize(Context context, AttributeSet attrs)

Constants

public static final int ANNOTATION_BUBBLE

Display the number of users who have +1'd the URL in a graphic next to the button (default).

Constant Value: 1

public static final int ANNOTATION_INLINE

Display profile pictures of connected users who have +1'd the URL and a count of users who have +1'd the URL.

Constant Value: 2

public static final int ANNOTATION_NONE

Do not render any additional annotations.

Constant Value: 0

public static final int DEFAULT_ACTIVITY_REQUEST_CODE

An empty ActivityRequestCode to serve as the default before the code has been assigned.

Constant Value: -1

public static final int SIZE_MEDIUM

The medium button size. See Button sizes for more information.

Constant Value: 1

public static final int SIZE_SMALL

The small button size. See Button sizes for more information.

Constant Value: 0

public static final int SIZE_STANDARD

The standard button size. See Button sizes for more information.

Constant Value: 3

public static final int SIZE_TALL

The tall button size. See Button sizes for more information.

Constant Value: 2

Public Constructors

public PlusOneButton (Context context)

Creates a +1 button of SIZE_STANDARD size with an ANNOTATION_BUBBLE annotation.

Parameters
context The context to use, usually your Activity.

public PlusOneButton (Context context, AttributeSet attrs)

Creates a +1 button of SIZE_STANDARD size with an ANNOTATION_BUBBLE annotation.

Parameters
context The context to use, usually your Activity.
attrs The attributes of the XML tag that is inflating the view.

Public Methods

public void initialize (String url, PlusOneButton.OnPlusOneClickListener plusOneClickListener)

Updates the +1 button with a client and URL. Most apps call this method each time the button is in focus (for example, in the Activity onResume method).

Parameters
url The URL to be +1'd.
plusOneClickListener A listener for +1 clicks.

public void initialize (String url, int activityRequestCode)

Updates the +1 button with a URL. Most apps call this method each time the button is in focus (for example, in the Activity onResume method). To use this method, the PlusOneButton must be placed in an Activity. Use initialize(String, OnPlusOneClickListener) otherwise.

Parameters
url The URL to be +1'd.
activityRequestCode The request code to use when opening the +1 Activity. This value must be an unsigned 16 bit integer.

public void plusOneClick ()

public void setAnnotation (int annotation)

Sets the annotation to display next to the +1 button. This can also be set using the attribute plus:annotation="none|bubble|inline".

Parameters
annotation The annotation. See ANNOTATION_NONE, ANNOTATION_BUBBLE, and ANNOTATION_INLINE.

public void setIntent (Intent intent)

public void setOnPlusOneClickListener (PlusOneButton.OnPlusOneClickListener listener)

Sets the PlusOneButton.OnPlusOneClickListener to handle clicks. Call this if you want to customize launching the +1 confirmation Activity from a +1 button click.

Parameters
listener The listener, or null for default behavior.

public void setSize (int size)

Sets the size of the +1 button. This can also be set using the attribute plus:size="small|medium|tall|standard".

Parameters
size The size. See SIZE_SMALL, SIZE_MEDIUM, SIZE_TALL, and SIZE_STANDARD.

Protected Methods

protected static int getAnnotation (Context context, AttributeSet attrs)

protected static int getSize (Context context, AttributeSet attrs)