2014-03-19 106 views
1

我從Web服務獲取值並填充textviews,並且我還在某些值上設置了標籤,因爲我必須在按鈕單擊時將這些值發送到其他活動上。但我只獲取數組的最後一個值。gettag()只獲取數組的最後一個索引值

txt_TransStatus 
         .setOnClickListener(new View.OnClickListener() { 

          @Override 
          public void onClick(View v) { 
           // TODO Auto-generated method stub 

           TextView cr = (TextView) child 
             .findViewById(R.id.txt_StatusValue); 
           TextView pid = (TextView) child 
             .findViewById(R.id.txt_DateValue); 
           TextView amount = (TextView) child 
             .findViewById(R.id.txt_RechargeAmountValue); 
           TextView phone = (TextView) child 
             .findViewById(R.id.txt_PhoneValue); 
           TextView pin = (TextView) child 
             .findViewById(R.id.txt_PinNumberValue); 

           Intent intent = new Intent(con, 
             GetTransData.class); 
           intent.putExtra("CRID", cr.getTag() 
             .toString()); 
           intent.putExtra("PID", pid.getTag() 
             .toString()); 
           intent.putExtra("Amount", amount.getTag() 
             .toString()); 
           intent.putExtra("Phone", phone.getTag() 
             .toString()); 
           intent.putExtra("PINNum", pin.getTag() 
             .toString()); 
           con.startActivity(intent); 

          } 
         }); 

回答

1

我固定我的代碼以這樣的:

OnClick方法,改變了我的代碼

ImageView iv = (ImageView)v; 
ProductURL = (String) iv.getTag(); 
相關問題