public final class

PlusOneButton

extends ViewGroup
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.google.android.gms.plus.PlusOneButton

Class Overview

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.

Summary

Nested Classes
interface PlusOneButton.OnPlusOneClickListener A listener for +1 button clicks. 
Constants
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 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.
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PlusOneButton(Context context)
Creates a +1 button of SIZE_STANDARD size with an ANNOTATION_BUBBLE annotation.
PlusOneButton(Context context, AttributeSet attrs)
Creates a +1 button of SIZE_STANDARD size with an ANNOTATION_BUBBLE annotation.
Public Methods
void initialize(PlusClient plusClient, String url, PlusOneButton.OnPlusOneClickListener plusOneClickListener)
Updates the +1 button with a client and URL.
void initialize(PlusClient plusClient, String url, int activityRequestCode)
Updates the +1 button with a PlusClient and URL.
void setAnnotation(int annotation)
Sets the annotation to display next to the +1 button.
void setOnPlusOneClickListener(PlusOneButton.OnPlusOneClickListener listener)
Sets the PlusOneButton.OnPlusOneClickListener to handle clicks.
void setSize(int size)
Sets the size of the +1 button.
[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

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 (0x00000001)

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 (0x00000002)

public static final int ANNOTATION_NONE

Do not render any additional annotations.

Constant Value: 0 (0x00000000)

public static final int SIZE_MEDIUM

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

Constant Value: 1 (0x00000001)

public static final int SIZE_SMALL

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

Constant Value: 0 (0x00000000)

public static final int SIZE_STANDARD

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

Constant Value: 3 (0x00000003)

public static final int SIZE_TALL

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

Constant Value: 2 (0x00000002)

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 (PlusClient plusClient, 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
plusClient The PlusClient.
url The URL to be +1'd.
plusOneClickListener A listener for +1 clicks.

public void initialize (PlusClient plusClient, String url, int activityRequestCode)

Updates the +1 button with a PlusClient and 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(PlusClient, String, OnPlusOneClickListener) otherwise.

Parameters
plusClient The PlusClient.
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 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 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.