我正在做一个项目,我只需要向用户显示基本信息,如果他选择查看更多,他可以点击卡片,展开卡片会下拉。此功能已通过使用“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 种不同的内部布局)