Search code examples
androidandroid-listviewandroid-image

how to hide image button in a list view on android


in my app i use list view with image button called buy video. i populate video list from urban air ship. if i press buy button the video is downloaded. how to hide image button at a particular position in a list view. i did but the right position and some other position image button also hide. please help me.

i check whether installed(downloaded) or not by the code:

if(statusOfProduct.equals("INSTALLED")){
  ....
  buy.setVisibility(View.INVISIBLE);
}  

main code :

public class InventoryListActivity extends ListActivity {
 ...........

    public class InventoryAdapter extends BaseAdapter implements Observer,OnClickListener
{ 
     ..........  
     public View getView(int position, View convertView, ViewGroup parent) {
        Product product = (Product) getItem(position);
        View view;
            if(statusOfProduct.equals("INSTALLED")){
                Log.e("vocab","if-status");
                Log.e("vocab",product.getIdentifier());
                buy.setVisibility(View.INVISIBLE); // hide right position and some other position image button also.

            } 
}

please help me. i do not the reason.


Solution

  • Though it is not clear from your code, this may solve your problem : In place of

    buy.setVisibility(View.INVISIBLE);
    

    Use

    ((Button) pConvertView.findViewById(R.id.buyButtonID)).setVisibility(View.INVISIBLE);