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 al开发者_JAVA技巧so 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.
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);
I wasn't totally sure what you were asking, but there is a difference between VIEW.INVISIBLE and VIEW.GONE. Make sure you're using the right one for your needs.
try this
yourBtn = (ImageButton) view.getRootView().findViewById(R.id.YOUR_BUTTON_ID);
and then try this
yourBtn.setVisibility(View.GONE);
精彩评论