我正在开展一个项目,我只需向用户显示基本信息,如果他选择查看更多信息,他可以点击卡片,扩展卡会下拉。使用'addCardExpand'实现了此功能。
但是,我现在希望在此扩展卡中添加另一张扩展卡,该扩展卡应该下拉,即当我点击之前的扩展卡时可以看到。基本上,一个2层扩展卡机制。
扩展卡没有实现'addCardHeader'功能,因此,添加相同功能已证明是一个问题。谁能给我一些关于如何进行的指示?
card[i] = new Card(activity);
//Create a CardHeader
header[i] = new CardHeader(activity);
int j = 0;
header[i].setId(String.valueOf(i+1000));
header[i].setTitle(s); //Set the header title
//Add Header to card
card[i].addCardHeader(header[i]);
final int finalI = i;
final int finalI1 = i;
card[i].setShadow(true);
CustomCardExpand expand = new CustomCardExpand(activity,i,curTab);
/* Code block where I am trying to add the second expandable card */
CardViewNative chart_card = new CardViewNative(activity);
Card chart_expand = new Card(activity);
CardHeader chart_header = new CardHeader(activity);
chart_header.setTitle("Click to view chart");
chart_header.setButtonExpandVisible(true);
CustomInnerCardExpand chart = new CustomInnerCardExpand(activity);
CustomCardExpand chart = new CustomCardExpand(activity,i,curTab);
chart_expand.addCardExpand(chart);
chart_expand.addCardHeader(chart_header);
ViewToClickToExpand viewToClickToExpand1 =
ViewToClickToExpand.builder()
.setupView(chart_card);
chart_expand.setViewToClickToExpand(viewToClickToExpand1);
chart_card.setCard(chart_expand);
expand.setCardView(chart_card);
/* Code Block ends */
card[i].addCardExpand(expand); //Adding the first card expand
cardExpands[i] = new CardViewNative(activity);
ViewToClickToExpand viewToClickToExpand =
ViewToClickToExpand.builder()
.setupView(cardExpands[i]).highlightView(false);
card[i].setViewToClickToExpand(viewToClickToExpand);
cardExpands[i].setCard(card[i]);
cardExpands[i].setCardElevation(activity.getResources().getDimension(R.dimen.carddemo_shadow_elevation));
cardExpands[i].setCardBackgroundColor(R.color.card_background);
cardExpands[i].setBottom(R.color.card_background);
cardExpands[i].setRadius(R.dimen.card_background_default_radius);
cards_ll.addView(cardExpands[i]);
这是CustomCardExpand类:
public class CustomCardExpand extends CardExpand {
private Context mContext;
public static TextView[] tx;
public static TextView filter;
public static int MYCODE = 200;
int j;
public static String tabName;
public static ArrayList<String> pageDimensions;
public CustomCardExpand(Context context, int i,String tableName) {
super(context, R.layout.card_inner_layout);
mContext = context;
j=i;
tabName = tableName;
MobiReportHolderSmallDeviceAdapter.tableHeaderMap.put(Integer.toString(j), tabName);
}
@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
//...Populated with some textviews wrapped in a horizontal scrollview
}
}
CustomInnerCard类是第二张可扩展卡的独立类:(我希望下拉的2张卡有2种不同的内部布局)