0

I'm working with the CardUI found here.

I would like to inflate these cards with my own layout xml but I do not understand how to.

Here is code for the MainActivity creating the cards

MyCard facebookCard = new MyCard("Continue with Facebook");
MyCard noSignInCard = new MyCard("Continue without log in");

mCardView.addCard(facebookCard);
mCardView.addCard(noSignInCard);

Here is the class for 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;
}




}

I believe i am supposed to use getCardContent for inflating but I'm sure how to use context.

Any help would be greatly appreciated.

Sammy Kumar
  • 121
  • 3
  • 15

1 Answers1

1

You only need replace R.layout.card_ex with your new layout. Here is another example:

https://github.com/nadavfima/cardsui-for-android/blob/master/CardsExample/src/com/cardsui/example/MyImageCard.java

mromer
  • 1,867
  • 1
  • 13
  • 18
  • Ah yes but that would make the layout the same for all of the cards correct? How would I change that on a card basis. I feel like I may need to implement that method in myself, not sure. Theres not a lot of documentation on this library but its sucha great android design. – Sammy Kumar Jul 18 '13 at 11:38
  • You create a type of card with `public class MyCardType1 extends Card ` and you can create all MyCardType that you need changing the layout. Then you add this cards: `mCardView.addCard(myCardType1); mCardView.addCard(myCardType2);` – mromer Jul 18 '13 at 11:47
  • So for every new card layour I want I should amkea new class, correct? – Sammy Kumar Jul 18 '13 at 12:28
  • Thank, you have been very helpful. – Sammy Kumar Jul 18 '13 at 13:26
  • i used same card ui but how to get position on click of that perticular card ? – Joseph Mekwan Nov 28 '15 at 10:57
  • i have following question : http://stackoverflow.com/questions/33969946/android-how-to-pass-value-with-intent-in-cardview – Joseph Mekwan Nov 28 '15 at 10:58