GridView默认项高亮

参考:http://blog.sina.com.cn/s/blog_9cf7416701014hvn.html

设置底部导航菜单栏默认第一项目高亮,只需要在它的Adapter里面的getView方法中判断是不是第一个,然后,设置背景Drawn

public View getView(int position, View convertView, ViewGroup parent) {

		ImageView imageView;
		TextView textView;
		convertView = LayoutInflater.from(mContext).inflate(R.layout.menu_adapter, null);
		imageView = (ImageView) convertView.findViewById(R.id.imageView_icon);
		imageView.setImageResource(picIds[position])/*imgItems[position]*/;
		textView = (TextView) convertView.findViewById(R.id.textview_icon);
		textView.setText(textItems[position]);
		if (position == 0) {//默认选择第0项
			convertView.setBackgroundResource(R.drawable.main_tab_bg_d);
		}
		return convertView;
	}


你可能感兴趣的:(null)