Skip to content

Instantly share code, notes, and snippets.

@zmdominguez
Created November 11, 2018 21:12
Show Gist options
  • Save zmdominguez/55bda05e5d26dba341f58b70cbe123c5 to your computer and use it in GitHub Desktop.
Save zmdominguez/55bda05e5d26dba341f58b70cbe123c5 to your computer and use it in GitHub Desktop.
Effectively Wrangling Views via Groups
@BindView(R.id.checkbox) CheckBox mCheckbox;
@BindView(R.id.container) ViewGroup mContainer;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_constraint);
ButterKnife.bind(this);
mCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mContainer.setVisibility(View.VISIBLE);
} else {
mContainer.setVisibility(View.GONE);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment