This is my showDialog function, which gets call when someone clicks on a button in activity.
private void showCouponCodeDialog() {
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialoge_apply_coupon);
dialog.setTitle(R.string.coupon_code);
final ProgressBar progressBar = (ProgressBar) dialog.findViewById(R.id.progressBar);
progressBar.setVisibility(View.GONE);
Button btnApplyCoupon = (Button) dialog.findViewById(R.id.btnApplyCoupon);
btnApplyCoupon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);
}
});
dialog.show();
}
when i do
@Bind(R.id.progressBar) ProgressBar progressBar;
It gives error @Bind not applicable to local variable.
This works fine.
final ProgressBar progressBar = (ProgressBar) dialog.findViewById(R.id.progressBar);
How to use butterknief's Bind() in this case?
Using
Butterknife
you might use such bind methods:or
The second one is better as it suggests, where (in which class) binds are hold. Remember, that those functions return
Unbinder
and it is really imprortant to unbind, when dialog is destroyed, otherwise memory leaks might occur.