首页 > 代码库 > gridview

gridview

public class HomeAdapter extends BaseAdapter
{
	public int getCount()
	{
		return names.length;
	}

	public View getView(int position, View convertView, ViewGroup parent)
	{
		View view = View.inflate(getApplicationContext(), R.layout.home_item, null);
		TextView tv = (TextView) view.findViewById(R.id.tv_homeitem_name);
		ImageView iv = (ImageView) view.findViewById(R.id.iv_homeitem_icon);
		tv.setText(names[position]);
		iv.setImageResource(icons[position]);

		return view;
	}

	public Object getItem(int position)
	{
		return null;
	}

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


private static final String names[] = { "手机防盗", "通讯卫士", "软件管理", "进程管理", "流量统计", "手机杀毒", "系统优化", "高级工具", "设置中心" };
private static final int icons[] = { R.drawable.safe, R.drawable.callmsgsafe, R.drawable.app,R.drawable.taskmanager, R.drawable.netmanager, R.drawable.trojan, R.drawable.sysoptimize,R.drawable.atools, R.drawable.settings };