android 的gridview如何把最后一个item固定做一个添加更多的按钮
1个回答
展开全部
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.menu_listvview, null);
viewHolder = new ViewHolder();
viewHolder.title = (TextView) convertView
.findViewById(R.id.title11);
viewHolder.image = (ImageView) convertView
.findViewById(R.id.image11);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
if (position < pictures.size()) {
viewHolder.title.setText(pictures.get(position).getTitle());
viewHolder.title.setTextColor(color.turquoise);
viewHolder.image.setImageResource(pictures.get(position).getImageId());
}else {
// viewHolder.image.setBackground(context.getResources().getDrawable(R.drawable.add_more));
}
// viewHolder.deleteView.setVisibility(isShowDelete ? View.VISIBLE : View.GONE);// 设置删除按钮是否显示
// viewHolder.deleteView.setOnClickListener(new OnClickListener() {
//
// @Override
// public void onClick(View v) {
// viewHolder.deleteView.setSelected(isDown);
// }
//
// });
viewHolder.title.setText(pictures.get(position).getTitle());
viewHolder.title.setTextColor(color.turquoise);
viewHolder.image.setImageResource(pictures.get(position).getImageId());
return convertView;
}
}
LayoutInflater inflater = LayoutInflater.from(context);
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.menu_listvview, null);
viewHolder = new ViewHolder();
viewHolder.title = (TextView) convertView
.findViewById(R.id.title11);
viewHolder.image = (ImageView) convertView
.findViewById(R.id.image11);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
if (position < pictures.size()) {
viewHolder.title.setText(pictures.get(position).getTitle());
viewHolder.title.setTextColor(color.turquoise);
viewHolder.image.setImageResource(pictures.get(position).getImageId());
}else {
// viewHolder.image.setBackground(context.getResources().getDrawable(R.drawable.add_more));
}
// viewHolder.deleteView.setVisibility(isShowDelete ? View.VISIBLE : View.GONE);// 设置删除按钮是否显示
// viewHolder.deleteView.setOnClickListener(new OnClickListener() {
//
// @Override
// public void onClick(View v) {
// viewHolder.deleteView.setSelected(isDown);
// }
//
// });
viewHolder.title.setText(pictures.get(position).getTitle());
viewHolder.title.setTextColor(color.turquoise);
viewHolder.image.setImageResource(pictures.get(position).getImageId());
return convertView;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询