I'm a student of android developer. I need to make a project and I've ran into a problem. basically the problem is that i need to make the box of a checkBox disappear and only after pushing a specific button, the box will appear and be clickable. from my searches i've found that when i write:
myCheckBox.setButtonDrawable(new ColorDrawable(Color.TRANSPARENT));
it will disappear and it's good but couldn't find the way to make it appear after that.. thanks a lot. :)
You can achieve that my making the view disappear either by using
myCheckBox.setVisibility(View.GONE);
(OR)
myCheckBox.setVisibility(View.INVISIBLE);
And again you can make it to appear by
myCheckBox.setVisibility(View.VISIBLE);
Hope this is helpful:)
You need to use
yourCheckBox.setVisibility(View.GONE);
to make that visible again,
yourCheckBox.setVisibility(View.VISIBLE);
You can get the currently assigned drawable with getButtonDrawable()
and store it in a field, for example:
class Foo {
private Drawable oldDrawable;
private CheckBox myCheckBox;
public void hideCheckbox() {
oldDrawable = myCheckBox.getButtonDrawable();
myCheckBox.setButtonDrawable(new ColorDrawable(Color.TRANSPARENT));
}
public void showCheckbox() {
myCheckBox.setButtonDrawable(oldDrawable);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.