2016-10-02 5 views
1

私のアプリにgoogle +ボタンを追加します。 <com.google.android.gms.plus.PlusOneButton/>レイアウトにAndroidのGoogle PlusOneButtonを追加するとコンパイルエラーが発生する

バイナリXMLファイルのライン#31:バイナリXMLファイルのライン#31:エラー膨張クラスI、クラスPlusOneButtonも、XMLタグを実装することはできませんどちらも https://developers.google.com/+/mobile/android/recommend

:私はこの命令に従っcom.google.android.gms.plus.PlusOneButton

XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="16dp" 
    android:paddingStart="16dp" 
    android:paddingRight="16dp" 
    android:paddingEnd="16dp" 
    android:background="@color/primary_light" 
    android:paddingTop="@dimen/custom_margin_top_bottom" 
    android:paddingBottom="@dimen/custom_margin_top_bottom"> 

    <TextView 
     android:id="@+id/nachrichtTv" 
     android:layout_width="match_parent" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:layout_height="wrap_content" 
     android:textColor="@color/white" 
     android:singleLine="true" 
     android:ellipsize="marquee" 
     /> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <com.google.android.gms.plus.PlusOneButton 

      android:id="@+id/plus_one_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      /> 


    </LinearLayout> 

</LinearLayout> 

答えて

0

これは、あなたがそれを行うことができる方法である。

のGradleに入れる:

compile 'com.google.android.gms:play-services:7.3.0' 

あなたlayout.xmlボタンを追加するには:最後に

<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" /> 

あなたにアクティビティここにPlusOneButtonがあります:

PlusOneButton plusOneButton =(PlusOneButton) findViewById(R.id.plus_one_button); 

    plusOneButton.initialize(URL, 0); 
+0

ボタンのデザインが気に入らず、通常のものを使用したい場合。どのように行動を追加できますか? – XxGoliathusxX

関連する問題