0
我想要在用戶單擊下面的按鈕時EditText
上的String
爲空時顯示一個對話框。 所以我做了這種方法,但不幸的是,而不是顯示一個對話框,應用程序崩潰。對話框方法沒有問題,問題是IF函數沒有正確讀取我所請求的內容。單擊按鈕並且EditText字符串爲空時顯示對話框
有人有解決方案嗎?
這裏是我的方法:
public void onClick(View v) {
if(v == launchSimplePayment) {
String amount = paymentAmount.getText().toString();
System.out.println(amount);
if (amount == "")
{
errorDialog();
}
else
{
System.out.println(amount);
// Use our helper function to create the simple payment.
PayPalPayment payment = exampleSimplePayment();
// Use checkout to create our Intent.
Intent checkoutIntent = PayPal.getInstance().checkout(payment, this, new ResultDelegate());
// Use the android's startActivityForResult() and pass in our Intent. This will start the library.
startActivityForResult(checkoutIntent, request);
}
}