首页 > 代码库 > 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 };
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。