I have worked for a long time on this problem. I want to show a Button if CheckBox is checked. I have CheckBoxes in number of columns in my DataBase. And If the Checkbox is unchecked i want to hide this Button. I see in this Forum this way, but it wasnt work right in my program.
btn.setVisibility(View.GONE);
btn.setVisibility(View.VISIBLE);
And my program shows:
private void AddColum(int count) {
final LinearLayout ll = (LinearLayout)findViewById(R.id.ListLayout);
for(int i=1; i<=count; i++) {
final int id_ = createCheckBox(i, ll);
CheckBox checkbox = (CheckBox) findViewById(id_);
final IsCheck check = new IsCheck();
checkbox.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Button open = createButton(id_,ll);
if (check.getCheck()) {
open.setVisibility(View.VISIBLE);
open.setText("Ac");
open.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(ListActivity.this, ShowActivity.class);
myIntent.putExtra("ID", id_);
ListActivity.this.startActivity(myIntent);
}
});
check.setCheck(false);
} else {
open.setVisibility(View.GONE);
check.setCheck(true);
}
}
});
}
}
Aucun commentaire:
Enregistrer un commentaire