4

I have a Gridview and Custom adapter.

in my adapter, i have a static ViewHolder instance.

static class ViewHolder
{ 
  TextView _model,tPrice,pPrice;
  ImageView picture;
}

This is my ViewHolder. When the user clicked a button in the fragment, I just want to make tPrice visibility GONE. When i create a istance of the adapter i send an integer parameter for tPrice VISIBLITY. But its data still on the static data. I wanna change the this area. i need an instance of my current view. i will cast it to my ViewHolder. After do this i set the visiblity. But How can I do it?

Here are the getView and my constructer

private int TFV = View.GONE;
private int PFV=  View.GONE;

public ProductGridViewAdapter(Context p_context, int p_resourceId,ArrayList<Product> p_ProductList,int TFVisib,int PFVisib){
    super(p_context,p_resourceId,p_ProductList);
    originalItems = p_ProductList;
     TFV = TFVisib;
     PFV = PFVisib;
    _ctx = p_context;
    //....
}

public View getView(int position, View convertView, ViewGroup parent) {   
    ViewHolder holder = null;
    View row = convertView;
    if(row==null){
        holder = new ViewHolder();      
        row = li.inflate(_resourceId, null);
        holder._model = (TextView) row.findViewById(R.id.o_model);    
        holder.pPrice = (TextView) row.findViewById(R.id.product_pf);  
        holder.tPrice = (TextView) row.findViewById(R.id.product_tf);  
        holder.picture = (ImageView)row.findViewById(R.id.product_lv_image);
        row.setTag(holder);
    }else{
        holder = (ViewHolder) row.getTag();
    }

    Product f =null;

    if(originalItems!=null)
         f = originalItems.get(position);
    if (f != null) {
         holder._model.setText(f.GetCODE());
         holder.pPrice.setText(f.GetPRICE());
         holder.pPrice.setVisibility(PFV);
         holder.tPrice.setVisibility(TFV);
         holder.tPrice.setText(f.GetCURRENCY());
         File imgFile = new  File(uhandler.GetProductsFolderPath()+"/BIG"+f.GetCODE()+".jpg");
         if(imgFile.exists()){
             Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
             holder.picture.setImageBitmap(myBitmap);
         }
    }
    return row;
}
Twinsens
  • 417
  • 6
  • 23

2 Answers2

0

In your custom adapter class, look at the getView() method, in which you can set GONE or VISIBLE or INVISIBLE value to the tPrice TextView or any Views if you want.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • tPrice VISIBILITY is VISIBLE okey. When i clicked the button, i send a data to adapter, this data trigger the visiblity but i still visible – Twinsens Apr 02 '13 at 04:50
  • when click event triggered the instance of the adapters parameter will changed on the fragment – Twinsens Apr 02 '13 at 05:00
0

i solved my problem. I had set the adapter again. This way may be a bad way but its work :)

Twinsens
  • 417
  • 6
  • 23