Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在安卓系统中制作具有自定义布局的google plus按钮?_Android_Icons - Fatal编程技术网

Android 如何在安卓系统中制作具有自定义布局的google plus按钮?

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:

我想为我的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: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
    来处理登录过程
  • 例如,我可以提供用于处理Google Plus登录的控制器类:

    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按钮。。但无论如何,我会给你正确的答案;)