gpt4 book ai didi

android - 从 EditText 获取值时出错?

转载 作者:搜寻专家 更新时间:2023-11-01 07:59:06 25 4
gpt4 key购买 nike

我正在将 paypal 集成到我的应用程序中。我需要从 Edittext 中获取金额。我尝试使用 String 类型,但 PayPalPayment 方法在 BigDecimal 中。这是抛出错误

构造函数 BigDecimal(BigDecimal) 未定义

所以请纠正我......

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);
}

最佳答案

也许你需要更换

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);

关于android - 从 EditText 获取值时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23834796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com