Android 如何在安卓系统中制作具有自定义布局的google plus按钮?
我想为我的google plus按钮创建一个自定义布局,有什么想法吗?我尝试调用google plus按钮的onClick事件(不起作用),并尝试更改背景图像。源代码:Android 如何在安卓系统中制作具有自定义布局的google plus按钮?,android,icons,Android,Icons,我想为我的google plus按钮创建一个自定义布局,有什么想法吗?我尝试调用google plus按钮的onClick事件(不起作用),并尝试更改背景图像。源代码: <com.google.android.gms.plus.PlusOneButton xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" android:
<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);
holder.mPlusOneButton=(PlusOneButton)holder.content.findViewById(R.id.plus_one_按钮);
holder.mPlusOneButton.initialize(“http://www.xxx.xx/", 0);
OnClickListener
设置为自定义按钮PlusClient
来处理登录过程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 this method in your click handler
public void login() {
try {
connectionResult.startResolutionForResult(activity, REQUEST_CODE_SIGN_IN);
} catch (IntentSender.SendIntentException e) {
googlePlusClient.connect();
}
}
// call this method in your activity's onActivityResult
public void onActivityResult() {
if(!googlePlusClient.isConnected() && !googlePlusClient.isConnecting()) {
googlePlusClient.connect();
}
}
@Override
public void onConnected(Bundle bundle) {
// connected, you can now get user's data from
// 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();
}
}
}
某种程度上解决了:谷歌说:“你只能在提供的格式中使用+1按钮。你不能使用另一个图像来表示+1按钮的功能。”-对不起,我的问题很模糊,我指的是谷歌+1按钮。。但无论如何,我会给你正确的答案;)