Android: Why setVisibility (View.GONE);或 setVisibility(View.INVISIBLE);不工作
2022-08-31 14:08:13
我希望我的和按钮在开始时不可见。当我按下我的魔术按钮时,我想设置可见度(View.Visible);DatePicker
这里的问题是当我或什么都不改变并且组件仍然可见时。setVisibility(View.GONE)
setVisibility(View.INVISIBLE)
final DatePicker dp2 = (DatePicker) findViewById(R.id.datePick2);
final Button btn2 = (Button) findViewById(R.id.btnDate2);
dp2.setVisibility(View.GONE);
dp2.setVisibility(View.INVISIBLE);
btn2.setVisibility(View.GONE);
btn2.setVisibility(View.INVISIBLE);
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
TextView txt2 = (TextView) findViewById(R.id.txt2);
txt2.setText("You selected " + dp2.getDayOfMonth()
+ "/" + (dp2.getMonth() + 1) + "/" + dp2.getYear());
}
});