Search code examples
androidcardslib

Different Layouts inside CardsWithList cardslib Library


Im using Cardslib inside my project Is it possible to inflate another Layouts inside the CardsWithList? I want to add a somekind of footer at the end which would be clickable to open another fragment


Solution

  • If you want to use different layouts for each row in CardWithList, you can't do it.

    If you want to use a custom layout for the

    As other cards you can use a custom inner layout instead of the default layout. You can set it in your constructor for example:

    public WeatherCard(Context context) {
        super(context,R.layout.carddemo_extras_inner_base_main_cardwithlist);
    }
    

    Your layout have to provide an element with `

    <it.gmariotti.cardslib.library.prototypes.LinearListView
            android:id="@+id/card_inner_base_main_cardwithlist"
        />
    

    Also you can add other elements inside you layout.
    In this case you have to set them with the method setupInnerViewElements. In this case it is very important to call the super method.

     @Override
        public void setupInnerViewElements(ViewGroup parent, View view) {
            //It is very important call the super method!!
            super.setupInnerViewElements(parent, view);
    
            //Your elements
        }
    

    You can find more info here: