J'ai une View
et cette vue contient un Point
. Je voudrais lier des données à ce point, mais autant que je comprenne je ne peux pas créer un attribut personnalisé dans attrs.xml
avec un Point
comme format.Liaison d'une vue personnalisée à un point
est la vue:
public class MyView extends android.support.v7.widget.AppCompatImageView {
private Point point;
public MyView(Context context) {
super(context);
}
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
}
}
Et ceci est MyObject:
public class MyObject extends BaseObservable {
private Point point;
@Bindable
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
notifyPropertyChanged(BR.point);
}
}
Et maintenant, je veux lier MyView quelque chose comme ceci:
<MyView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:point="@{myObject.point}"/>
et un fichier attrs.xml
comme ceci:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="MyView">
<attr name="point" format="Point" />
</declare-styleable>
</resources>
Mais cela ne semble pas possible. Est-ce que quelqu'un connaît une solution?