public final class

PlusOneButton

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ 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
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. 
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 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.
[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(String url, PlusOneButton.OnPlusOneClickListener plusOneClickListener)
Updates the +1 button with a client and URL.
void initialize(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.
Protected Methods
static int getAnnotation(Context context, AttributeSet attrs)
static int getSize(Context context, AttributeSet attrs)
[Expand]
Inherited Methods
From class android.widget.FrameLayout
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 DEFAULT_ACTIVITY_REQUEST_CODE

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

Constant Value: -1 (0xffffffff)

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 (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 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(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 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.

Protected Methods

protected static int getAnnotation (Context context, AttributeSet attrs)

protected static int getSize (Context context, AttributeSet attrs)