首页 > 解决方案 > Stripe Android - AddPaymentMethodActivityStarter 获取页脚布局事件

问题描述

我正在集成条纹的添加卡片屏幕。

使用 stripe 的 AddPaymentMethodActivityStarter 启动添加卡屏幕

使用以下代码:

// launch stripe's add card UI

 new AddPaymentMethodActivityStarter(StripeAddCardActivity.this).startForResult(
                        new AddPaymentMethodActivityStarter.Args.Builder()
                                .setAddPaymentMethodFooter(R.layout.stripe_footer_layout)
                                .build());


//initalize checkbox

CheckBox stripeSaveCardCheckbox = findViewById(R.id.stripeSaveCardCheckbox);

if(stripeSaveCardCheckbox !=null){
   if(stripeSaveCardCheckbox.isChecked()){
     Toast.makeText(this, "save card", Toast.LENGTH_LONG).show();
       }else{
           Toast.makeText(this, "don't save card",Toast.LENGTH_LONG).show();
        }
     }else{
        Toast.makeText(this, "CHECKBOX NULL", Toast.LENGTH_LONG).show();
       }

我需要获取页脚布局(R.layout.stripe_footer_layout)的复选框值。但即使在初始化它之后,我总是得到空值。

谁能帮我从条纹的添加卡片屏幕中获取页脚 XML 值?

stripe_footer_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:background="@color/white"
    android:layout_height="wrap_content">
    <CheckBox
        android:id="@+id/stripeSaveCardCheckbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:background="@color/transparent"
        android:button="@drawable/checkbox_portmonie_selector"
        android:checked="true"
        android:paddingStart="10dp"
        android:layout_marginTop="8dp"
        android:singleLine="true"
        android:fontFamily="@fonts/helvetica_new"
        android:textSize="@dimen/community_avis_16px"
        android:text="@string/hint_card_checkbox_content"
        android:textColor="@color/community_black_color" />
</LinearLayout>

标签: javaandroidstripe-payments

解决方案


推荐阅读