문제

UPDATE: I found out that this is my issue https://code.google.com/p/google-plus-platform/issues/detail?id=704

A while ago I implemented the +1 button in my app as a preference. It worked well until a few weeks and now the button is always gray. If I touch it I get the 'loading' circle and it never stops rotating.

I've debugged my app and made sure that initialize is called.

Is anyone else experiencing problem with it?

Thanks.

My preference code:

public class PlusOnePreference extends Preference { 

public PlusOnePreference(Context context) {
    super(context);     
}

public PlusOnePreference(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public PlusOnePreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

@Override
protected void onBindView(View view) {
    super.onBindView(view);
    PlusOneButton plusOneButton = (PlusOneButton)view.findViewById(R.id.plus_one_button);
    plusOneButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
}
}

My preference layout:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.plus.PlusOneButton xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:layout_gravity="center_vertical"
android:focusable="false"
android:descendantFocusability="blocksDescendants"
plus:size="standard" 
plus:annotation="inline"/>
도움이 되었습니까?

해결책 2

This seems to be fixed with Google Play Services 4.1 .

다른 팁

So I was having problems with this because the Google plus one icon would stay grey like you stated until the preference view was reloaded (i.e. navigating else where and then coming back, having the preference scroll out of the screen and then back, etc). The problem is because you need to make a call to mPlusOneButton.initialize() in the onResume() function of the activity that has the Plus One Button. So basically, I just made a public method in the preference that makes the initialize call and then called it in the onResume() function.

The Activity:

Preference preference; 
@Override
public void onResume()
{
    super.onResume();
    if(preference!= null)
    {
        preference.reloadGooglePlusOneButton();
    }

}

In the preference:

public void reloadGooglePlusOneButton()
{
    if(mPlusOneButton != null)
    {
        mPlusOneButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top