我在我的App中集成了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);
}
答案 0 :(得分:3)
也许你需要更换
BigDecimal amt = (BigDecimal) amount.getText();
到
BigDecimal amt = new BigDecimal(amount.getText().toString());
<强>更新强>
替换
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);
到
EditText amount = (EditText) findViewById(R.id.amtdon);
BigDecimal amt = new BigDecimal(amount.getText().toString());
PayPalPayment payment = new PayPalPayment(atm, "USD", "Donate Remote IT ", PayPalPayment.PAYMENT_INTENT_SALE);
答案 1 :(得分:1)
尝试这样做
BigDecimal amt = new BigDecimal(amount.getText().toString);