2013-04-22 90 views
0

所以我試圖讓用戶進入一個給定的GPS位置後,圖像視圖改變它的圖像,但我的應用程序保持關閉,只要我到達這個位置,我可以使TextView的變化改變其文字,所以我認爲它會有點相同的圖像,但顯然它不是大聲笑。位置變化的圖像變化

我把這個在我的public class activity: ImageView sprite;

我有我使用的是「IF」語句,這樣每個位置這只是後setContentView: sprite = (ImageView)findViewById(R.id.imageView1);

if(pLat >= homeLat - 0.0001000 && pLat <= homeLat + 0.0001000 
&& pLong >= homeLong - 000.0002000 && pLong <=  homeLong + 000.0002000) 
    { 

    gateway.setText(R.string.home); 
    gatewayDis.setText(R.string.homeD); 
         sprite.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.minimap)); 
      // the image change is the only part that isn't working 
} 

任何幫助將是非常感謝你。

回答

0

您需要從下面的代碼行改變

sprite.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.minimap)); 

sprite.setImageDrawable(this.getResources().getDrawable(R.drawable.minimap)); 
+0

好的,謝謝你,這是第二個其他男士回答這個工作,謝謝反正 – 2013-04-24 06:11:10

0

嘗試這種情況:

sprite.setImageResource(R.drawable.minimap);

+0

好的,謝謝你們,這是爲我工作雖然 – 2013-04-24 06:09:36