Skip to content

Commit

Permalink
CheckedImageView增加接口
Browse files Browse the repository at this point in the history
  • Loading branch information
wecodexyz committed Oct 11, 2017
1 parent 03e89b7 commit 022882b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
Expand All @@ -16,8 +17,8 @@
public class CheckedImageView extends AppCompatImageView {
boolean mChecked = false;

Drawable mNormalState;
Drawable mCheckedState;
protected Drawable mNormalState;
protected Drawable mCheckedState;

public CheckedImageView(Context context) {
super(context);
Expand Down Expand Up @@ -72,4 +73,10 @@ public void setChecked(boolean checked) {
setImageDrawable(mNormalState);
}
}

public void setImageDrawableState(@NonNull Drawable checkedState, @NonNull Drawable normalState) {
mCheckedState = checkedState;
mNormalState = normalState;
setChecked(mChecked);
}
}

0 comments on commit 022882b

Please sign in to comment.