所以我基本上想知道如果填写了txtCode或StreetCode,我将如何允许用户在他们点击付款时继续到下一页,只需要填写这两个中的一个才能传递到下一页但是如何我让它工作,因为目前他们都必须填写才能传递到下一页。
btnPay = (Button)findViewById(R.id.btnPay);/** REFERENCE THE PAY BUTTON*/
btnPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {/** SETS ONCLICKLISTENER TO LISTEN FOR BUTTON CLICK*/
/** REFERENCES ALL VARIABLE TO FIELDS IN LAYOUT */
txtReg = (EditText)findViewById(R.id.txtReg);
txtCode = (EditText)findViewById(R.id.txtCode);
txtStreetName = (EditText)findViewById(R.id.txtStreetName);
dlCostTime = (Spinner)findViewById(R.id.dlCostTime);
if( txtReg.getText().toString().trim().equals(""))
{
txtReg.setError("required!");
}
if( txtCode.getText().toString().trim().equals(""))
{
txtCode.setError("required!");
}
if( txtStreetName.getText().toString().trim().equals(""))
{
txtStreetName.setError("required!");
}
else{
final Button btnPay = (Button) findViewById(R.id.btnPay);
btnPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent payIntent = new Intent(UserAreaActivity.this, PaymentActivity.class);// creates intent to open payment details
UserAreaActivity.this.startActivity(payIntent);//Performs intent to open payment page
}
});
}