【问题标题】:Stripe CardInputWidget not showing on the new updateStripe CardInputWidget 未在新更新中显示
【发布时间】:2021-08-14 00:44:25
【问题描述】:

升级条带实现后 CardInputWidget 不再出现:/

错误: 膨胀类 com.stripe.android.view.CardInputWidget 时出错

大实现:

实现'com.stripe:stripe-android:16.9.0'

付款对话框的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="350dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:fitsSystemWindows="false">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center_vertical"
            android:padding="8dp">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:src="@drawable/card_outline_stripe" />

            <com.example.dev.customs.CustomTextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_gravity="center"
                android:layout_marginTop="8dp"
                android:text="@string/enter_your_payment_method"
                android:textSize="20sp"
                app:fontTextView="MuseoSans-900" />

            <com.stripe.android.view.CardInputWidget
                android:id="@+id/dialogue_edit_payment_card"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layoutDirection="ltr"
                android:layout_marginTop="5dp"
                android:padding="3dp"
                android:background="@drawable/bg_stripe_payment"
                android:textDirection="ltr" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="5dp">

                <Button
                    android:id="@+id/btn_submit"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="end"
                    android:text="@string/label_submit"
                    android:padding="3dp"
                    android:textStyle="bold"
                    android:textSize="16sp"
                    android:textColor="@color/gradient_blue_1"
                    android:background="@drawable/btn_submit_bg"/>
            </LinearLayout>
        </LinearLayout>
    </androidx.cardview.widget.CardView>
</RelativeLayout>

代码:

btnStartPlan.setOnClickListener(new View.OnClickListener() { 显示支付对话框();} ...

dialog.setContentView(R.layout.dialog_payment);

【问题讨论】:

  • 你有更多的上下文吗?您使用的是什么版本/API 级别的 Android?这是在物理设备还是模拟器上?您是否尝试过对项目进行全新的 Gradle 同步?
  • 你好,是的,我做了一个项目清理和重建。我在物理设备上进行测试(三星、OPPO、华为、lge nexus 5x)版本 8、9、10

标签: java android stripe-payments


【解决方案1】:

这个问题解决了, 问题是当我将 'androidx.appcompat:appcompat:' 的版本更改为 1.3.0 或 1.4.0-alpha02 时,条带支付的 CardInputWidget 不会在布局中膨胀并导致崩溃,

'com.stripe:stripe-android:16.10.2'的新版本解决了这个问题。

请, 检查此链接:https://github.com/stripe/stripe-android/issues/3770

编码愉快。

【讨论】:

  • 当链接这样的问题时(尤其是需要阅读大量内容),您应该在答案中添加关于如何修复它的描述(例如“问题是 X,更新到版本Y 或更高版本来修复")
  • 感谢@KelvinSchoofs 的评论,我是回答问题的新手,当我解决任何问题时,我会尝试添加我的答案。
猜你喜欢
  • 2019-06-17
  • 2015-06-19
  • 1970-01-01
  • 1970-01-01
  • 2019-02-15
  • 2017-11-27
  • 2016-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多