控制元件呼叫自定義類的方法事,怎么將自身設定為引數傳遞進去。如下面代碼:
這是我自定義類中的兩個方法:
public static String addColonString(int id){
return "";
}
public static String addColonString(TextView view, int id){
return "";
}
在xml中要使用這個方法
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="2"
android:text="@{Util.addColonString(@string/consume_type)}"
android:textSize="@dimen/sp_14"
android:textColor="@color/context_text_color"/>
現在這樣設定引數只能對應到addColonString(int id)
那么要怎么才能對應到addColonString(TextView view, int id)
uj5u.com熱心網友回復:
同求,樓主找到解決辦法了,麻煩發我一份,非常感謝!郵箱:[email protected]uj5u.com熱心網友回復:
android:onClick="@{(view) ->Util.addColonString(view,@string/consume_type)}"轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/120835.html
標籤:Android
