2014-09-05 16 views
0

我想爲我的pinIt按鈕使用自定義圖標。當我在預覽中顯示我喜歡的圖標時運行我的應用程序時,我不斷獲取舊的佈局。如何在SDK的PinItButton中使用自定義圖標?

<com.pinterest.pinit.PinItButton 
     android:id="@+id/car_info_comment_pintrest" 
     android:layout_width="@dimen/car_info_button_width" 
     android:layout_height="wrap_content" 
     android:background="@drawable/ic_comment_pintrest" 
     android:drawableTop="@drawable/ic_comment_pintrest" 
     android:text="100" 
     android:textColor="#fff" /> 

回答

0

我已經使用hacky解決方案修復了它。我添加了另一個按鈕,並調用PinIt按鈕的OnClickEvent,並使按鈕可見性消失。

holder.mPinterestButton = ((PinItButton) holder.content.findViewById(R.id.pin_it)); 
    holder.mPinterestButton.setImageUrl("http://placekitten.com/400/300"); 
    holder.mPinterestButton.setUrl("http://placekitten.com"); // optional 
    holder.mPinterestButton.setDescription("A place kitten!"); // optional 
    holder.pinterestButton = ((Button) holder.content.findViewById(R.id.car_info_comment_pinterest)); 
    holder.pinterestButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      holder.mPinterestButton.performClick(); 
     } 
    }); 

XML:

  <Button 
      android:id="@+id/car_info_comment_pinterest" 
      android:layout_width="@dimen/car_info_button_width" 
      android:layout_height="wrap_content" 
      android:drawableTop="@drawable/ic_comment_pinterest" 
      android:background="@null" 
      android:text="100" 
      android:textColor="#fff" /> 

     <com.pinterest.pinit.PinItButton 
      android:id="@+id/pin_it" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:visibility="gone" 
      /> 
相關問題