我希望我DatePicker
的和按钮在开始时是不可见的。当我按下我的魔法按钮时,我想 setVisibility(View.Visible);
这里的问题是当我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());
}
});