Myadapter

package com.example.xmllist;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



public class MyBaseAdapter extends BaseAdapter {

    private ArrayList list;
    private Context context;

    public MyBaseAdapter(Context context, ArrayList list) {
        this.context = context;
        this.list = list;
    }

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

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(context, R.layout.lv_item, null);
        TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
        TextView tv_body = (TextView) view.findViewById(R.id.tv_body);
        TextView tv_pubDate = (TextView) view.findViewById(R.id.tv_pubDate);
        tv_title.setText(list.get(position).getTitle());
        tv_body.setText(list.get(position).getBody());
        tv_pubDate.setText(list.get(position).getPubDate());
        return view;
    }
}

你可能感兴趣的:(Myadapter)