Android Open Source - android-dobleembrague Item List Adapter






From Project

Back to project page android-dobleembrague.

License

The source code is released under:

MIT License

If you think the Android project android-dobleembrague 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.davidgg.dobleembrague.rss;
//from  w w w . j a v a2 s. 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 java.text.SimpleDateFormat;
import java.util.ArrayList;

/**
 * Custom Adapter
 * list_item.xml
 *
 * @author DavidGG
 */
public class ItemListAdapter extends ArrayAdapter<RSSItem> {

    private ArrayList<RSSItem> items;

    public ItemListAdapter(Context context, int textViewResourceId,
                           ArrayList<RSSItem> items) {
        super(context, textViewResourceId, items);
        this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_item, null);
        }
        RSSItem item = items.get(position);
        if (item != null) {
            TextView textTitulo = (TextView) v
                    .findViewById(R.id.TextViewGeneralTitulo);
            TextView textCreadorFecha = (TextView) v
                    .findViewById(R.id.TextViewGeneralAutorFecha);
            if (textTitulo != null) {
                textTitulo.setText(item.getTitle());
            }
            if (textCreadorFecha != null) {
                SimpleDateFormat sdf = new SimpleDateFormat("dd/MM");
                String fecha = sdf.format(item.getPubDate());
                textCreadorFecha.setText(this.getContext().getString(
                        R.string.adapterCreador)
                        + " " + item.getCreator() + " " + fecha + "\n");
            }
        }
        return v;
    }
}




Java Source Code List

com.davidgg.dobleembrague.rss.ItemListAdapter.java
com.davidgg.dobleembrague.rss.News.java
com.davidgg.dobleembrague.rss.Preferences.java
com.davidgg.dobleembrague.rss.RSSItemDisplayer.java
com.davidgg.dobleembrague.rss.RSSItem.java
com.davidgg.dobleembrague.rss.WidgetLastNews.java