2012-03-21 60 views
0

我如何manupilate在ListView中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); 
+0

你已經問過這裏確切的相同的問題http://stackoverflow.com/questions/9795418/conditionally-change- imagebutton-image /和你有幫助的迴應 – 207 2012-03-21 12:34:30

回答

0

啓用/禁用,ü意味着:imgB.setVisibility(View.VISIBLE)/imgB.setVisibility(View.GONE)? 要操縱圖像您可以檢索其drawable並做任何你想要的與它:imgB.getDrawable()