这是我的Adapter类
public class GridViewCustomAdapter extends BaseAdapter {
private List<ProductParameterBO> availList;
private LayoutInflater inflater;
Context context;
public GridViewCustomAdapter(Context ctx,List<ProductParameterBO> list){
this.context = ctx;
this.availList = list;
}
@Override
public int getCount() {
return availList.size();
}
@Override
public Object getItem(int position) {
return availList.get(position);
}
@Override
public long getItemId(int position) {
ProductParameterBO c = availList.get(position);
// long id = c.getTimeId();
return 0;
}
@Override
public View getView(final int position,View convertView,final ViewGroup parent) {
View row = convertView;
final TeeTimeHolder holder;
if (row == null){
inflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.grid_row,parent,false);
holder = new TeeTimeHolder();
holder.myImage =(ImageView)row.findViewById(R.id.imageView10);
holder.imageflip =(ImageView)row.findViewById(R.id.img_flp);
holder.name =(TextView)row.findViewById(R.id.textView47);
holder.edit =(TextView)row.findViewById(R.id.textView49);
holder.rl =(RelativeLayout)row.findViewById(R.id.grid_img_ovrly);
// holder.row =(RelativeLayout)row.findViewById(R.id.row);
row.setTag(holder);
}
else {
holder =(TeeTimeHolder)row.getTag();
}
holder.name.setText(availList.get(position).getParameterName());
holder.myImage.setImageResource(R.drawable.toi);
holder.rl.setVisibility(View.GONE);
return row;
}
static class TeeTimeHolder {
ImageView myImage,imageflip;
TextView name,edit;
RelativeLayout rl;
}
}
我只想在选择行时显示Relativelayout r1,当我选择下一行时,前一行必须隐藏Relativelayout r1布局并显示在选中的行上。现在在我的情况下,当我选择下一行时,则它没有隐藏在上一行..layout仍显示在我选择的所有行上。
请帮助我解决这个问题..在高级的任何帮助将不胜感激..
答案 0 :(得分:0)
int priviousPosition=0;
ArrayList<View> viewList= new ArrayList<View>();
holder.rl.setTag(position);
viewList.add(holder.rl);
row.findViewById(R.id.grid_img_ovrly).setOnClickListener(new OnClickListener() {
public void onClick(View v1) {
View v=viewList.get(priviousPosition);
v.setVisibility(View.GONE);
int postition=(Integer) v1.getTag();
priviousPosition=postition;
notifyDataSetChanged();
}
});