简单的自定义baseAdapter

package com.example.myapp.app.adapter;

import java.util.List;

import com.example.myapp.R;

import android.R.integer;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
@SuppressLint("all")
public class MenuAdapter extends BaseAdapter {
	private List<String> listStr;
	private List<integer> listDrawable;
	private List<String> listNum;
	private Context context;
	
	
	public MenuAdapter(List<String> listStr, List<String> listNum,
			Context context) {
		super();
		this.listStr = listStr;
		this.listNum = listNum;
		this.context = context;
	}
	//初始化像是item数量
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listStr.size();
	}
	//返回string
	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return listStr.get(arg0);
	}
	//返回id
	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
	//返回View
	@Override
	public View getView(int i, View v, ViewGroup vg) {
		LayoutInflater inflater = LayoutInflater.from(context);
		View view = inflater.inflate(R.layout.menuadapter, null);
		ImageView imageView = (ImageView) view.findViewById(R.id.id_menuIcon);
		TextView menuText = (TextView) view.findViewById(R.id.id_menuText);
		TextView menuTextNum =(TextView) view.findViewById(R.id.id_menuTextNum);
		imageView.setImageResource(R.drawable.listviewhander);
		menuText.setText(listStr.get(i));
		menuTextNum.setText(listNum.get(i));
		return view;
	}


}

你可能感兴趣的:(简单的自定义baseAdapter)