2016-08-16 3 views
0

Я только что познакомился с каркасом Butterknife для привязки поля. Моя проблема заключается в том, что я получаю следующее сообщение об ошибке компиляции при реализации в одном нож для масла из моих фрагментов, который работает отлично, пока я использовал findViewById()Рамка Butterknife, обработка включенных макетов для нескольких переменных виджетов

Error:(52, 65) error: Attempt to use @BindView for an already bound ID 3454353 on 'tvRFCExt'. (com.org.ui.fragments.SummaryFragment.tvRFCElect)

Фрагмент

@BindView(R.id.tv_rfc)TextView tvRFCExt; 
@BindView(R.id.tv_rfc)TextView tvRFCElect; 
@BindView(R.id.rt_bar)RatingBar ratingBarExt; 
@BindView(R.id.rt_bar)RatingBar ratingBarElect; 

onCreateView(){ 
    mView = inflater.inflate(R.layout.fragment_summary, container, false); 
} 

fragment_summary.xml включает в себя макет, который похожи. Оба имеют панель «Оценка» и «Текстовый».

<include 
android:id="@+id/viewRatingExtTyres" 
layout="@layout/rating_view"></include> 
<!-- rating--> 
<include 
android:id="@+id/viewRatingElecInter" 
layout="@layout/rating_view"></include> 

Прилагаемый макет выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/colorWhite" 
    android:orientation="horizontal" 
    android:weightSum="4"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.2" 

     > 

     <TextView 
      android:id="@+id/tv_Title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_margin="2dp" 
      android:gravity="center_vertical" 
      android:paddingLeft="@dimen/margin_10" 
      android:textColor="@color/gray_text" 
      android:textSize="@dimen/text_apperance_small" /> 
     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/tv_Title" 
      android:layout_height="wrap_content"> 

     <RatingBar 
      android:id="@+id/rt_bar" 
      style="?android:attr/ratingBarStyle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:max="100" 
      android:numStars="5" 
      android:progressTint="@color/colorSubmitBtn" 
      android:rating="0" 
      android:saveEnabled="false" 
      android:stepSize="0" /> 
</LinearLayout> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="2.6"> 

     <TextView 
      android:id="@+id/tv_rfc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginLeft="@dimen/margin_10" 
      android:layout_marginTop="@dimen/margin_5" 
      android:gravity="center_vertical" 
      android:text="@string/txt_rfc" 
      android:textColor="@color/gray_text" 
      android:textSize="@dimen/text_apperance_medium" /> 

     <View 
      android:id="@+id/line" 
      android:layout_width="match_parent" 
      android:layout_height="1dp" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/tv_rfc" 
      android:layout_margin="5dp" 
      android:background="@color/row_color_text"></View> 


     <TextView 
      android:id="@+id/tv_rating" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/line" 
      android:layout_marginLeft="@dimen/margin_10" 
      android:gravity="center_vertical" 
      android:text="@string/txt_no_rting" 
      android:textColor="@color/gray_text" 
      android:textSize="@dimen/text_apperance_medium" /> 

    </RelativeLayout> 


</LinearLayout> 

Теперь это работает отлично с findViewById() подходом. Какие изменения мне нужно будет сделать, чтобы обеспечить работу базы Butterknife.

+0

попробовать '@BindView (R.id.viewRatingExtTyres) LinearLayout линейный;' – piotrek1543

ответ

0

попробуйте использовал этот код:

onCreateView(){ 
mView = inflater.inflate(R.layout.fragment_summary, container, false); 
ButterKnife.bind(this, mView);} 

 Смежные вопросы

  • Нет связанных вопросов^_^