2017-03-29 5 views
2

をデータバインディングでパラメータとして別のビューを渡します次のように...私はバインディングGoogleデータ内のメソッドのパラメータとしての私のXMLの別のビューに合格しようとしています

<LinearLayout 
    android:id="@+id/faq_subject_about_ego" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/border_faq_btn" 
    android:orientation="horizontal" 
    android:layout_marginBottom="20dp" 
    android:padding="4dp" 
    android:gravity="center" 
    android:onClick='@{(faq_title_about) -> viewModel.subjectRequest(faq_title_about.getText())}'> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/icon_faq" 
     android:layout_marginRight="8dp" 
     android:clickable="false" /> 

    <ebanx.com.ego.utils.custom_extension.CustomButtonBold 
     android:id="@+id/faq_title_about" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/Button_FAQ" 
     android:text="@string/btn_about_ego" 
     android:clickable="false" /> 
</LinearLayout> 

私はそのテキストを必要とします私のCustomButtonBoldにあります...しかし、これは動作していません。

ボタンのテキストをパラメータとして渡すにはどうすればよいですか?

助けてください!

答えて

3

id-able用に生成されたメンバーにはCamelCaseの名前形式があります。また、OnClickListenerに提供されるビューは、クリックされたビューです。パラメータを任意に指定し、正しい "グローバル"メンバーを使用するだけです。

android:onClick='@{(v) -> viewModel.subjectRequest(faqTitleAbout.getText())}' 
+0

感謝しました! –

関連する問題