-5
我有4個EditText
,我在XML中設置爲invisible
,當單擊button
時,我希望它們可以成對顯示。例如,當單擊button
的時候,我想et1
和et2
可見,那麼當按鈕被再次點擊eet1
和eet2
可見。而當所有的人都看到,我想TextView
可見。設置EditText的可見度
public class app extends ActionBarActivity {
EditText et1;
EditText et2;
EditText eet1;
EditText eet2;
TextView sum;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app);
et1 = (EditText)findViewById(R.id.et1);
et2 = (EditText)findViewById(R.id.et2);
eet1 = (EditText)findViewById(R.id.eet1);
eet2 = (EditText)findViewById(R.id.eet2);
sum = (TextView)findViewById(R.id.sum);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClick();
}
});
}
public void onClick() {
et1.setVisibility(View.VISIBLE);
eT1.setVisibility(View.VISIBLE);
eet1.setVisibility(View.VISIBLE);
eet2.setVisibility(View.VISIBLE);
}
}
謝謝非常。這是工作。 @mrtn – jj7