naX*_*aXa 2 android android-drawable butterknife
如何使用ButterKnife注释消除以下初始化代码?
private Drawable mExpandDrawable;
private Drawable mCollapseDrawable;
void init() {
mExpandDrawable = getResources().getDrawable(R.drawable.ic_expand_small_holo_light);
mCollapseDrawable = getResources().getDrawable(R.drawable.ic_collapse_small_holo_light);
}
Run Code Online (Sandbox Code Playgroud)
naX*_*aXa 12
使用ButterKnife 7 API中的@BindDrawable.
import butterknife.BindDrawable;
@BindDrawable(R.drawable.ic_expand_small_holo_light)
protected Drawable mExpandDrawable;
@BindDrawable(R.drawable.ic_collapse_small_holo_light)
protected Drawable mCollapseDrawable;
void init() {
ButterKnife.bind(this);
}
Run Code Online (Sandbox Code Playgroud)
其他资源类型有@ bindString,@ bindInt,@ bindDimen,@ LabelColor,@ LabelBool.
| 归档时间: |
|
| 查看次数: |
2751 次 |
| 最近记录: |