2011-11-26 108 views
1

在我發佈我的問題之前,我已經做了一些研究,但沒有一個幫助。奇怪的部分是,它昨晚工作,我相信什麼都沒有改變。但是,我不能讓現在的工作,因爲findViewByID無故findViewByID突然返回null

public class ShowInMap extends MapActivity{ 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.mapview); 

    MapView mapView = (MapView) this.findViewById(R.id.mapview); 
    if(mapView == null) 
    { 
     Log.i("test", "test"); 
    } 
    } 
} 

返回null,這是我的MapView XML

<?xml version="1.0" encoding="utf-8"?> 
<com.google.android.maps.MapView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/mapview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:clickable="true" 
android:apiKey="Map Key" 
/> 

我想,也許我的調試密鑰已過期,但如果是這樣的,我應該從Eclipse中得到一些錯誤,說我的密鑰已過期或者什麼?我不應該嗎?這有點令人沮喪,任何評論將不勝感激。謝謝

+1

我不認爲有一個關鍵的問題。如果有,它會去地圖,但會顯示白色的瓷磚。 –

回答

3

嘗試清洗構建。這發生在我現在每時每刻。通常,如果我只是清理構建,然後進行完整的重建,事情似乎就行得通。

+0

非常感謝!它剛剛工作!我不知道爲什麼,也不想知道。 2個小時的挖掘讓我發瘋。真的很感激它 –