gpt4 book ai didi

android - 我的 Google+1 按钮显示为灰色且无法使用?

转载 作者:太空宇宙 更新时间:2023-11-03 11:14:05 24 4
gpt4 key购买 nike

我正在尝试将 G+ 按钮集成到 ma 应用程序中。G+ 按钮变灰了。它不计数。如何变成红色?

          public class HomeActivity extends SherlockActivity implements ConnectionCallbacks, OnConnectionFailedListener{

private static final String URL = "https://play.google.com/store/apps/details?id=com.phoneix.allu";
private static final int PLUS_ONE_REQUEST_CODE = 0;
private static final int REQUEST_CODE_RESOLVE_ERR = 9000;

private ProgressDialog mConnectionProgressDialog;
private PlusClient mPlusClient;
private ConnectionResult mConnectionResult;
private PlusOneButton mPlusOneStandardButton;

@Override
public void onCreate(Bundle pBundle) {
super.onCreate(pBundle);
setContentView(R.layout.dashboard);

mPlusOneStandardButton = (PlusOneButton) findViewById(R.id.plus_one_standard_button);


mPlusClient = new PlusClient.Builder(this, this, this)

.build();


}

@Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
// Refresh the state of the +1 button each time we receive focus.

mPlusOneStandardButton.initialize(URL, PLUS_ONE_REQUEST_CODE);

}

@Override
public void onDisconnected() {
// Nothing to do.
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if (mConnectionProgressDialog.isShowing()) {
// The user clicked the sign-in button already. Start to resolve
// connection errors. Wait until onConnected() to dismiss the
// connection dialog.
if (result.hasResolution()) {
try {
result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch (SendIntentException e) {
mPlusClient.connect();
}
}
}

// Save the intent so that we can start an activity when the user clicks
// the sign-in button.
mConnectionResult = result;
}

public void onConnected(Bundle connectionHint) {
mPlusOneStandardButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
}

最佳答案

Try out this:

在 xml 文件中:

    <com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="92dp" >
</com.google.android.gms.common.SignInButton>

</RelativeLayout>

在您的 Activity 中获取该按钮:

    @Override
public void onCreate(Bundle pBundle) {
super.onCreate(pBundle);
setContentView(R.layout.dashboard);

findViewById(R.id.sign_in_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick
(View v) {
Intent i = new Intent(getApplicationContext(),YourActivity.class);
startActivity(i);
}
});
}

关于android - 我的 Google+1 按钮显示为灰色且无法使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19828441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com