icons - How do I make a google plus button with a custom layout in android? -
i want create custom layout google plus button, ideas? i've tried calling onclickevent of google plus button (that doesn't work) , i've tried changing background image. source code:
<com.google.android.gms.plus.plusonebutton xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" android:id="@+id/plus_one_button" android:layout_width="wrap_content" android:layout_height="wrap_content" plus:size="standard" plus:annotation="inline"/> holder.mplusonebutton = (plusonebutton) holder.content.findviewbyid(r.id.plus_one_button); holder.mplusonebutton.initialize("http://www.xxx.xx/", 0);
- add custom button layout
- set
onclicklistener
custom button - use
plusclient
described here handle login procedure
as example can provide controller class handling google plus login:
public class googlepluslogincontroller implements googleplayservicesclient.connectioncallbacks, googleplayservicesclient.onconnectionfailedlistener { public static final int request_code_sign_in = 100; private plusclient googleplusclient; private connectionresult connectionresult; private activity activity; public googlepluslogincontroller(activity activity) { this.activity = activity; googleplusclient = new plusclient.builder(activity, this, this) .setactions("http://schemas.google.com/addactivity") .setscopes(scopes.plus_login) // space separated list of scopes .build(); googleplusclient.connect(); } // call method in click handler public void login() { try { connectionresult.startresolutionforresult(activity, request_code_sign_in); } catch (intentsender.sendintentexception e) { googleplusclient.connect(); } } // call method in activity's onactivityresult public void onactivityresult() { if(!googleplusclient.isconnected() && !googleplusclient.isconnecting()) { googleplusclient.connect(); } } @override public void onconnected(bundle bundle) { // connected, can user's data // googleplusclient.getcurrentperson() } @override public void ondisconnected() { } @override public void onconnectionfailed(connectionresult result) { connectionresult = result; } private void logout() { if(googleplusclient.isconnected()) { googleplusclient.cleardefaultaccount(); googleplusclient.disconnect(); googleplusclient.connect(); } } }
Comments
Post a Comment