我正在使用找到的here CardUI。
我想用我自己的布局xml来充气这些卡但是我不明白怎么做。
以下是创建卡片的MainActivity的代码
MyCard facebookCard = new MyCard("Continue with Facebook");
MyCard noSignInCard = new MyCard("Continue without log in");
mCardView.addCard(facebookCard);
mCardView.addCard(noSignInCard);
这是myCard的课程
package com.kc.umassguide;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.fima.cardsui.objects.Card;
public class MyCard extends Card {
public MyCard(String title){
super(title);
}
@Override
public View getCardContent(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.card_ex, null);
((TextView) view.findViewById(R.id.title)).setText(title);
return view;
}
}
我相信我应该使用 getCardContent 进行充气,但我确定如何使用上下文。
非常感谢任何帮助。
答案 0 :(得分:1)
您只需要用新布局替换R.layout.card_ex。这是另一个例子: