Android: MapView causing "Source not found."
I have :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
As a child of < manifest >.
I have :
<uses-library android:name="com.google.android.maps" />
As a child of < application >.
myview.xml contains:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/secondaryColor"
>
<com.google.android.maps.MapView
android:layout_width="260dp"
android:layout_height="100dp"
android:apiKey=OMMITTED
android:id="@+id/mapView"/>
</RelativeLayout>
MyView.java:
public class MyView extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.myview);
}
}
When I run the program, I get a "source not found" error with nothing in the console or the logcat. When I take out the entire com.google.android.maps.MapView tag, the program 开发者_JAVA百科runs fine. I'm running the simulator with target "Google APIs API Level 7". My project build target is "Google APIs" for API Level 7. I'm stuck at this point!
Change your Activity
to MapActivity
.
and also give the MapView
tag android:id="@+id/mapview"
in XML.
also override the method
@Override
protected boolean isRouteDisplayed() {
return false;
}
You need this : MyView extends MapActivity and on onCreate method mapView = (MapView) findViewById(R.id.mapView);
精彩评论