gpt4 book ai didi

android - 只有创建 View 层次结构的原始线程才能触及它的 View 。 Paypal MPL Android

转载 作者:太空宇宙 更新时间:2023-11-03 16:18:28 25 4
gpt4 key购买 nike

我正在使用 Paypal 的 MPL 开发处理捐赠的应用程序当你调用下一段代码时

// 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_PAYPAL_CHECKOUT);
Log.i(TAG, "Executo todo el procedimiento de paypal.");

付款完成后
1.- 使用 Paypal 凭据登录
2.- 在下一个 Activity 中按支付
3.- 输入电话号码和密码
4.- 按创建 Pin 按钮

显示下一个错误

AndroidRuntime  E  FATAL EXCEPTION: Thread-3504
AndroidRuntime E android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
AndroidRuntime E at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:5001)
AndroidRuntime E at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:970)
AndroidRuntime E at android.view.ViewGroup.invalidateChild(ViewGroup.java:4168)
AndroidRuntime E at android.view.View.invalidate(View.java:10248)
AndroidRuntime E at android.widget.TextView.invalidateRegion(TextView.java:4406)
AndroidRuntime E at android.widget.TextView.invalidateCursor(TextView.java:4349)
AndroidRuntime E at android.widget.TextView.spanChange(TextView.java:7239)
AndroidRuntime E at android.widget.TextView$ChangeWatcher.onSpanAdded(TextView.java:8847)
AndroidRuntime E at android.text.SpannableStringBuilder.sendSpanAdded(SpannableStringBuilder.java:979)
AndroidRuntime E at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:688)
AndroidRuntime E at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:588)
AndroidRuntime E at android.text.Selection.setSelection(Selection.java:76)
AndroidRuntime E at android.text.Selection.setSelection(Selection.java:87)
AndroidRuntime E at android.text.method.ArrowKeyMovementMethod.initialize(ArrowKeyMovementMethod.java:302)
AndroidRuntime E at android.widget.TextView.setText(TextView.java:3560)
AndroidRuntime E at android.widget.TextView.setText(TextView.java:3430)
AndroidRuntime E at android.widget.EditText.setText(EditText.java:80)
AndroidRuntime E at android.widget.TextView.setText(TextView.java:3405)
AndroidRuntime E at com.paypal.android.MEP.b.b.a(Unknown Source)
AndroidRuntime E at com.paypal.android.c.f.a(Unknown Source)
AndroidRuntime E at com.paypal.android.c.f$3.run(Unknown Source)

最佳答案

您需要在

中设置 TextView 的文本
runOnUiThread(new Runnable() {
@Override
public void run() {
//set TextView text here. Because only the UI thread can update UI.
}
});

关于android - 只有创建 View 层次结构的原始线程才能触及它的 View 。 Paypal MPL Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24315031/

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