因此,我正在recyclerView中实现this库。 但是在多个信用卡布局中,所有字段都是空的。
以下是我在LogCat中打印的唯一警告
D/5: Passing to Adapter
W/AllCapsTransformationMethod: Caller did not enable length changes; not transforming text
Caller did not enable length changes; not transforming text
W/AllCapsTransformationMethod: Caller did not enable length changes; not transforming text
D/2: BindViewHolder 0
W/AllCapsTransformationMethod: Caller did not enable length changes; not transforming text
W/AllCapsTransformationMethod: Caller did not enable length changes; not transforming text
W/AllCapsTransformationMethod: Caller did not enable length changes; not transforming text
D/2: BindViewHolder 1
这是我的代码,
@Override
public void onBindViewHolder(CardsAddAdapter.ViewHolder holder, int position) {
Cards.DataEntity cards = lists.get(position);
expirationMonth = cards.getExpirationMonth();
expirationYear = cards.getExpirationYear();
String expirationDate = expirationMonth + expirationYear;
holder.creditCardView.setCardNumber(cards.getCardNumber());
holder.creditCardView.setCardName(cards.getHolderName());
holder.creditCardView.setExpiryDate(expirationDate);
holder.creditCardView.putChip(true);
Log.d("2", "BindViewHolder "+position);
}
此外,由于我有多张卡(两张卡),因此recyclerView适配器将两次生成信用卡布局。
recycler_view.xml
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.vinaygaba.creditcardview.CreditCardView
android:layout_width="fill_parent"
android:layout_height="225dp"
android:background="@drawable/cardbackground_world"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
app:cardNumber="5500005555555559"
app:cardName="Vinay Gaba"
app:cardNumberTextColor="#cccccc"
app:cardNumberFormat="masked_all_but_last_four"
app:cardNameTextColor="#cccccc"
app:type="auto"
app:putChip="true"
app:expiryDate = "02/22"
app:expiryDateTextColor="#cccccc"
app:isEditable="true"
app:validTillTextColor="#cccccc"
app:hintTextColor = "#cccccc"
android:id="@+id/cardView"
/>
</ScrollView>
我认为代码量足够,但是如果需要,我愿意分享。