为什么我总是(FrameLayout)findViewById 总是返回null?该文件存在。使用谷歌地图。我阅读了相关主题。技术支持:项目清洁。删除文件夹生成。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.travel_map_activity);
mapView = (MapView) findViewById(R.id.travelMapView);
FrameLayout mainLayout = (FrameLayout) findViewById(R.id.mapFrame);//null
}
有什么问题?
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapFrame"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/tvTop"
android:layout_width="fill_parent"
android:layout_height="20dip"
android:background="#FFFFFF"
android:gravity="top|center_horizontal"
android:text="FLOATING VIEW - TOP"
android:textColor="#000000"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/lvMain"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout></FrameLayout>
travel_map_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
android:id="@+id/travelMapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="key" />
</LinearLayout>
谢谢