0

I'm working on a project where I need to show only the basic information to the user and if he chooses to see more, he can tap on the card and the expand card will drop down. This functionality has been achieved by using 'addCardExpand'.

However, I now wish to add another expand card to this expand card which should drop down i.e. be visible when I click on the earlier expand card. So basically, a 2 tier expand card mechanism.

The expand card does not implement the 'addCardHeader' function and hence, adding the same has proved to be a problem. Can anyone give me a few pointers on how to proceed?

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]);

This is the CustomCardExpand class :

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
     }
 }

And the CustomInnerCard class is a separate class for the second expandable card: ( I want the 2 cards which drop down to have 2 different inner layouts)

FormigaNinja
  • 1,571
  • 1
  • 24
  • 36
Nairiya
  • 33
  • 1
  • 5

0 Answers0