[android-developers] Re: Using onCreateDrawableState
Dianne,
Thanks for trying, but this did not clarify the issue for me. What
would really help would be some documentation about how drawable state
sets are supposed to work. Something beyond the 5 (poorly worded)
lines in the official Android docs. This is a case where a code
example just increases the confusion rather than clarifying it.
I modified my code as (I think) you are suggesting and I'm still not
seeing the expected behavior. I call toggle() from inside the onClick
method like this:
setOnClickListener( new OnClickListener(){
@Override
public void onClick(View arg0) {
toggle();
}});
I test the checked variable inside onCreateDrawableState like this:
@Override
public int[] onCreateDrawableState(int extraSpace) {
final int[] drawableState =
super.onCreateDrawableState(extraSpace + 1);
if (isChecked()) {
mergeDrawableStates(drawableState, CHECKED_STATE_SET);
}
return drawableState;
}
The methods for managing checked state look like this:
@Override
public boolean isChecked() {
return isChecked;
}
@Override
public void setChecked(boolean checked) {
isChecked = checked;
refreshDrawableState();
}
@Override
public void toggle() {
setChecked( !isChecked() );
}
But still the image is not being drawn as checked. What more do I need
to do?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home