部分布局:
<data>
<import type="android.view.View"></import>
<variable
name="tags"
type="java.util.HashMap"></variable>
</data>
查看xml:
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/overview_customerHashtags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:alignContent="flex_start"
app:alignItems="flex_start"
app:flexWrap="wrap"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/overview_tokenTimeout"
app:tags="@{tags}">
</com.google.android.flexbox.FlexboxLayout>
我的装订适配器:
@BindingAdapter("tags")
public static void setTags(FlexboxLayout flexboxLayout, HashMap<Integer, HashtagModel> hashtags) {
for (HashtagModel hashtagModel : hashtags.values()) {
flexboxLayout.removeAllViews();
HashtagButton button = new HashtagButton(flexboxLayout.getContext(), hashtagModel.getCategory());
int resId = flexboxLayout.getContext().getResources().getIdentifier(hashtagModel.getTitle().toUpperCase(), "string", flexboxLayout.getContext().getPackageName());
if (resId == 0) {
button.setText(hashtagModel.getDefault_text());
} else {
button.setText(flexboxLayout.getContext().getResources().getString(resId));
}
flexboxLayout.addView(button);
}
}
它一直给出这个错误:
错误:(162,29)无法找到属性&#39; app:标签&#39;同 参数类型java.util.HashMap on com.google.android.flexbox.FlexboxLayout。
有什么建议吗? 谢谢。