作者closer1018 (阿紅)
看板AndroidDev
標題[問題] 圖片轉換
時間Mon Oct 1 17:48:28 2012
小弟目前有兩張圖片 ((圖片A 圖片B))
目前使用LayoutParams、param.setMargins語法去設定...
但這兩個語法得..點擊圖片才會由A變到B...
不知道有沒有其他方法可以...假使一個回合結束後((使用者點擊後))
圖片直接由A變到B...
Bundle ab = this.getIntent().getExtras();
String t2_apple = ab.getString("t_apple");
total = Integer.parseInt(t2_apple);
count = total;
for (int i = 0; i < total; i++) {
LayoutParams param = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
image[i] = new ImageView(this);
image[i].setImageResource(R.drawable.play);
param.setMargins((i / 10) * 55 + 10, (i % 10) * 70 + 20, 0, 0);// (i/2)
layout.addView(image[i], param);
image[i].setOnClickListener(this);
}
public void onClick(View v)
{
v.setSelected(true);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 113.61.141.108
1F:推 motors55:看不出來你用的語法怎麼讓A變B,貼段code來看看吧 10/01 18:25
2F:→ motors55:直接換圖就好了吧 10/01 18:26
※ 編輯: closer1018 來自: 113.61.141.108 (10/01 23:24)
3F:→ closer1018:對 想要讓他直接換圖片 (((現在的是要點擊才能換 10/01 23:26
4F:推 motors55:開個執行緒定時做setImageResource 10/02 02:23
5F:→ MosilW:imageswitcher 10/04 17:47