Android Open Source - PECSMobile Card Grid Adapter






From Project

Back to project page PECSMobile.

License

The source code is released under:

GNU General Public License

If you think the Android project PECSMobile listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jjoseba.pecsmobile.adapter;
/*from  ww w.j  a v  a  2s  .c  o  m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.jjoseba.pecsmobile.R;
import com.jjoseba.pecsmobile.model.CardPECS;

import java.util.List;

/**
 * Created by Joseba on 28/12/2014.
 */
public class CardGridAdapter extends ArrayAdapter<CardPECS> {

    private List<CardPECS> cards;
    private Context _ctx;

    public CardGridAdapter(Context context, int layout, List<CardPECS> cards) {
        super(context, layout, cards);
        this.cards = cards;
        this._ctx = context;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) _ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View gridView;
        CardPECS card = cards.get(position);

        if (convertView == null) {

            gridView = new View(_ctx);

            // get layout from mobile.xml
            gridView = inflater.inflate(R.layout.card_gridview, null);

            // set value into textview
            TextView textView = (TextView) gridView
                    .findViewById(R.id.card_label);
            textView.setText(card.getLabel());

            // set image based on selected text
            //ImageView imageView = (ImageView) gridView
            //        .findViewById(R.id.grid_item_image);

        } else {
            gridView = (View) convertView;
        }

        return gridView;
    }

    @Override
    public int getCount() {
        return cards.size();
    }

    @Override
    public CardPECS getItem(int position) {
        return cards.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }
}




Java Source Code List

com.jjoseba.pecsmobile.ApplicationTest.java
com.jjoseba.pecsmobile.CardsPage.java
com.jjoseba.pecsmobile.activity.CardsActivity.java
com.jjoseba.pecsmobile.adapter.CardGridAdapter.java
com.jjoseba.pecsmobile.model.CardPECS.java
com.jjoseba.pecsmobile.ui.EnableableViewPager.java
com.jjoseba.pecsmobile.ui.GridItemClickedListener.java
com.jjoseba.pecsmobile.ui.SmoothScrollerViewPager.java
com.jjoseba.pecsmobile.ui.ZoomOutPageTransformer.java
com.jjoseba.pecsmobile.util.SystemUiHiderBase.java
com.jjoseba.pecsmobile.util.SystemUiHiderHoneycomb.java
com.jjoseba.pecsmobile.util.SystemUiHider.java