listview中的imagebutton

时间:2012-03-21 12:18:42

标签: android imagebutton

如何在列表视图中实现ImageButton的属性,我的意思是图像,启用和禁用按钮?

 public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.main, null);

    TextView title = (TextView)vi.findViewById(R.id.title); 
    TextView retail_price = (TextView)vi.findViewById(R.id.Retail_price);
    TextView deal_price = (TextView)vi.findViewById(R.id.Deal_price);
    TextView duration = (TextView)vi.findViewById(R.id.Time); 
    ImageButton imgB = ( ImageButton)vi.findViewById(R.id.imageButton1);
    TextView participants = (TextView)vi.findViewById(R.id.Particpant);  
    ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); 

    HashMap<String, String> otherdeals = new HashMap<String, String>();
    otherdeals = data.get(position);

   imgB.setImageResource(R.drawable.boutonachete);

1 个答案:

答案 0 :(得分:0)

启用/禁用,你的意思是:imgB.setVisibility(View.VISIBLE)/imgB.setVisibility(View.GONE)? 要操纵图像,你可以检索它的drawable并用它做任何你想做的事:imgB.getDrawable()