【发布时间】:2014-07-13 03:24:27
【问题描述】:
我正在将 paypal 集成到我的应用程序中。我需要从 Edittext 获取金额。
我尝试使用 String 类型,但 PayPalPayment 方法在 BigDecimal 中。
它正在抛出错误
The Constructor BigDecimal(BigDecimal) is undefined
所以请纠正我...
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.donate);
Intent intent = new Intent(this, PayPalService.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
startService(intent);
}
public void onBuyPressed(View pressed)
{
EditText amount = (EditText) findViewById(R.id.amtdon);
BigDecimal amt = (BigDecimal) amount.getText();
PayPalPayment payment = new PayPalPayment(new BigDecimal(amt), "USD", "Donate Remote IT ", PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(this, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
startActivityForResult(intent, 0);
}
【问题讨论】:
-
你遇到了什么错误?
-
您在
onCreate()中获得了amt,因此,除非您在那里有默认值,否则它将为空并给您一个解析错误。将其移至您的按钮单击方法。
标签: android paypal android-edittext