使用过滤器Android的自定义Listview适配器
package com.talagbe.schymn;import java.util.ArrayList;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.TextView;public class HymnsAdapter extends ArrayAdapter<Hymns> {ArrayList<Hymns> hymnarray;Context context;LayoutInflater inflater;int Resource;public HymnsAdapter(Context context, int resource, ArrayList<Hymns> objects) { super(context, resource, objects); // TODO Auto-generated constructor stub hymnarray=objects; Resource= resource; this.context=context; inflater= (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);}@Overridepublic View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ViewHolder holder; if(convertView==null){ convertView= inflater.inflate(Resource,null); holder= new ViewHolder(); holder.hymntitle= (TextView) convertView.findViewById(R.id.Hymn_title); // holder.hymntext= (TextView) convertView.findViewById(R.id.Channel_name); convertView.setTag(holder); }else{ holder=(ViewHolder)convertView.getTag(); } holder.hymntitle.setText(hymnarray.get(position).getTitle()); //holder.hymntext.setText(hymnarray.get(position).getText()); return convertView;} static class ViewHolder{ public TextView hymntitle; public TextView hymntext;} }
红颜莎娜
呼如林
相关分类