質問編集履歴
2
エラーを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,22 @@
|
|
26
26
|
android:layout_height="wrap_content"
|
27
27
|
app:backgroundTint="@{viewModel.hogeFlag ? @color/white : @color/black}"/>
|
28
28
|
```
|
29
|
-
これはビルドエラーになります。 backgroundTint は DataBinding で値を切り分けできないようです(違ってたらご指摘ください)
|
29
|
+
これは以下のビルドエラーになります。 backgroundTint は DataBinding で値を切り分けできないようです(違ってたらご指摘ください)
|
30
|
+
|
31
|
+
```
|
32
|
+
Cannot find a setter for <com.google.android.material.button.MaterialButton app:backgroundTint> that accepts parameter type 'int'
|
33
|
+
```
|
34
|
+
|
35
|
+
### 試したこと
|
36
|
+
@color/white ではなく、Rをimportし、
|
37
|
+
```XML
|
38
|
+
<com.google.android.material.button.MaterialButton
|
39
|
+
android:id="@+id/hoge_button"
|
40
|
+
android:layout_width="0dp"
|
41
|
+
android:layout_height="wrap_content"
|
42
|
+
app:backgroundTint="@{viewModel.hogeFlag ? R.color.white : R.color.black}"/>
|
43
|
+
```
|
44
|
+
でも同じエラーでした。
|
30
45
|
|
31
46
|
### 知りたいこと
|
32
47
|
私はこれをビルドエラーで知りました。しかしながら、これをビルドする前の段階で、backgroundTint は DataBinding で colos.xml に定義した color を設定できないことを知れれば、もっと実装の効率が上がると思います。
|
1
タイトルをわかりやすいものに変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Android の レイアウトの XML で DataBinding できるかどうかを調べる方法
|
1
|
+
Android の レイアウトの XML で ある属性が DataBinding で設定できるかどうかを調べる方法
|
test
CHANGED
File without changes
|