將簡要解釋發生了什麼。我想更新一個imageView,將其更改爲不同名稱的可繪製圖像。這裏只有四種選擇,這是因爲我正在從一個微調器中提取數據,微調器可以從其他活動中選擇4個國家。然後這將imageView更改爲所述國家的自定義可繪製圖像。根據字符串中的數據更改圖像視圖的顯示圖像(如單詞)
到目前爲止,我不確定我要如何做到這一點,嘗試了幾個非常基本的if else語句,但他們是非常不正確的。
我會後一些什麼,我有如下:
public class WorldImage extends AppCompatActivity {
TextView textCountry;
private String stringCountry;
ImageView imageCountry;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_worldimage);
Intent aIntent = getIntent();
stringCountry = aIntent.getStringExtra("movetoImageActivity");
textCountry= (TextView) findViewById(R.id.movetoviewCountry);
imageCountry = (ImageView) findViewById(R.id.imageCountry);
這是在這裏我迷路了,一些很基本的,如果& else if語句,如:
if (textCountry.getText().toString().equals("Europian Union"))
{
imageCountry.setImageResource(R.drawable.eu_flag);
}
會是什麼在這裏建議嗎?
嗯,這似乎並沒有任何工作,死機,甚至沒有給一個調試錯誤 – Hervel
好吧,這確實在-工作其實,很好,謝謝! – Hervel