I am trying to make a material card list but nothing is visible.
Here is my code:
<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
Created by hp1 on 21-01-2015.
*/
public class Tab3 extends Fragment {
final int TOTAL_CARDS = 3;
//private CardArrayAdapter
private CardArrayRecyclerViewAdapter mCardArrayAdapter;
private CardRecyclerView mRecyclerView;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v =inflater.inflate(R.layout.tab_3,container,false);
return v;
}
private ArrayList initCard() {
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 1 ; i++) {
// Toast.makeText(Tab3.this.getActivity(), " Inside initCard " + i, Toast.LENGTH_SHORT).show();
ArrayList<BaseSupplementalAction> actions = new ArrayList<BaseSupplementalAction>();
// Set supplemental actions
TextSupplementalAction t1 = new TextSupplementalAction(getActivity(), R.id.test_text3);
t1.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(), " Click on Text SHARE1 ", Toast.LENGTH_SHORT).show();
}
});
actions.add(t1);
TextSupplementalAction t2 = new TextSupplementalAction(getActivity(), R.id.test_text4);
t2.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(), " Click on Text LEARN1 ", Toast.LENGTH_SHORT).show();
}
});
actions.add(t2);
//Create a Card, set the title over the image and set the thumbnail
MaterialLargeImageCard card =
MaterialLargeImageCard.with(getActivity())
.setTextOverImage("Test Ground")
.setTitle("This is the first ground for test")
.setSubTitle("Lush Green outfield and a pacer friendly wicket full of runs, Easily approachable by Metro")
.useDrawableId(R.drawable.ic_ground)
.setupSupplementalActions(R.layout.material_card_layout, actions)
.build();
card.setOnClickListener(new Card.OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(), " Click on ActionArea ", Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(Tab3.this.getActivity(), " loop complete " + i, Toast.LENGTH_SHORT).show();
}
return cards;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//hideList(false);
//Set the arrayAdapter
ArrayList<Card> cards = new ArrayList<Card>();
mCardArrayAdapter = new CardArrayRecyclerViewAdapter(getActivity(), cards);
//Staggered grid view
CardRecyclerView mRecyclerView = (CardRecyclerView) getActivity().findViewById(R.id.carddemo_recyclerview);
mRecyclerView.setHasFixedSize(false);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//Set the empty view
if (mRecyclerView != null) {
mRecyclerView.setAdapter(mCardArrayAdapter);
}
//Load cards
new LoaderAsyncTask().execute();
Hi Gabriel,
I am trying to make a material card list but nothing is visible. Here is my code: <<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast;
import com.thoughtwings.sportus.R;
import java.util.ArrayList;
import it.gmariotti.cardslib.library.cards.actions.BaseSupplementalAction; import it.gmariotti.cardslib.library.cards.actions.TextSupplementalAction; import it.gmariotti.cardslib.library.cards.material.MaterialLargeImageCard; import it.gmariotti.cardslib.library.internal.Card; import it.gmariotti.cardslib.library.recyclerview.internal.CardArrayRecyclerViewAdapter; import it.gmariotti.cardslib.library.recyclerview.view.CardRecyclerView; import it.gmariotti.cardslib.library.view.CardViewNative;
/**
Created by hp1 on 21-01-2015. */ public class Tab3 extends Fragment {
final int TOTAL_CARDS = 3; //private CardArrayAdapter private CardArrayRecyclerViewAdapter mCardArrayAdapter; private CardRecyclerView mRecyclerView; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v =inflater.inflate(R.layout.tab_3,container,false); return v; }
private ArrayList initCard() {
}
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState);
}
private void updateAdapter(ArrayList cards) {
if (cards != null) {
mCardArrayAdapter.addAll(cards);
}
mCardArrayAdapter.notifyDataSetChanged();
}
class LoaderAsyncTask extends AsyncTask<Void, Void, ArrayList> {
} } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
<it.gmariotti.cardslib.library.view.CardViewNative xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card="http://schemas.android.com/apk/res-auto" android:id="@+id/list_cardId" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/native_recyclerview_card.base" card:card_layout_resourceID="@layout/native_material_largeimage_text_card"/>