1 在attrs.xml中加入
<declare-styleable name="MultiProgressBar"> <attr name="progress" format="integer"/> </declare-styleable>

2 修改构造函数,加入如下代码
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiProgressBar); this.currentValue = a.getInt(R.styleable.MultiProgressBar_progress, 0); a.recycle();
3.在代码中加入数据绑定注解(测试数据绑定会报错,但是正常使用属性是可以的)
@BindingAdapter({"progress"}) public void setProgress(View v,int progress){ this.currentValue = progress; update(); }

4.以上都没有问题后就可以在xml中使用了。看到progress出现了吗?

1658



被折叠的 条评论
为什么被折叠?



