我有两个复选框和两个 EditText。CheckBox 的 OnClick 使 EditText 消失并显示 Toast "Your Information is Saved"
。如果再次单击 CheckBox,则会显示另一个 Toast "Enter Your Email Address"
。虽然它正在工作,但两个 Toast 都在一个onClick
之后显示。有任何想法吗?
on.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (((CheckBox) v).isChecked())
receiverEmail.setVisibility(View.GONE);
if (((CheckBox) v).isChecked())
Toast.makeText(getApplicationContext(),
"Your Information is Saved", Toast.LENGTH_LONG).show();
else
receiverEmail.setVisibility(View.VISIBLE);
Toast.makeText(getApplicationContext(),
"Enter Your Email Address", Toast.LENGTH_LONG).show();
}
});
on2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (((CheckBox) v).isChecked())
clientID.setVisibility(View.GONE);
if (((CheckBox) v).isChecked())
Toast.makeText(getApplicationContext(),
"Your Information is Saved", Toast.LENGTH_LONG).show();
else
clientID.setVisibility(View.VISIBLE);
Toast.makeText(getApplicationContext(),
"Enter Your Email Address", Toast.LENGTH_LONG).show();
}
});