I'm looking for a way to expand a view when someone clicks on a checkbox.
If checkbox = true, the view expands. if false the view folds.
The basic idea is that I have a class newPokerGame and if the game is a tournament (the checkbox) some view will expand and you can select how many players etc.
I only don't know what's the best way to implement this. Any ideas?
Greets!
Asked
Active
Viewed 842 times
1

nostradamus
- 53
- 1
- 3
- 11
1 Answers
1
to listen to checkbox toggle, use onCheckChangedListener
yourCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if ( isChecked ) {
// show the view
} else {
// hide the view
}
}
});
to implement "expanding" view, create the layout that you'd want to expand/collapse as you want it to be seen in expanded mode, and just set the visibility of the layout that encloses it inside onCheckChanged. use View's setVisibility(View.VISIBLE);
or setVisibility(View.GONE);

josephus
- 8,284
- 1
- 37
- 57
-
Thanks, but how do I implement the expandable view? – nostradamus Apr 09 '12 at 09:30