I am trying to create a map application and I need to do something
similar to what Google Maps does.
I want to open show a list of locations and when user taps on them I
want to show a dialog.
I was able to do it till here. But now when the user clicks on the
dialog that opened I want to show another acttivity with the details
of that item that they clicked on.
I tried to start a new intent but it gives me an error.
Here is what I am doing
private void drawPopupWindow(Canvas canvas,int index, MapView mapView,
boolean shadow) {
OverlayItem item = mOverlays.get(index);
GeoPoint geoPoint = item.getPoint();
LayoutInflater inflater =
(LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout dialogLayout =
(LinearLayout)inflater.inflate(R.layout.location_dialog, null);
LayoutParams mapDialogParams = new LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
geoPoint, -1, -22,
LayoutParams.BOTTOM_CENTER);
mapView.addView(dialogLayout, mapDialogParams);
dialogLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent detailIntent = new Intent(mContext,
ItemDetailView.class);
mContext.startActivity(detailIntent); // I
passed the context from
mapActivity
}
});
}
Here is the stack trace
E/AndroidRuntime( 4985): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.achie.test.mapssample/
com.achie.test.mapssample.ItemDetailView}:
android.view.InflateException: Binary XML file line #2: Error
inflating class <unknown>
E/AndroidRuntime( 4985): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2496)
E/AndroidRuntime( 4985): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2512)
E/AndroidRuntime( 4985): at android.app.ActivityThread.access
$2200(ActivityThread.java:119)
E/AndroidRuntime( 4985): at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 4985): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4985): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 4985): at
android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 4985): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4985): at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 4985): at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 4985): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 4985): at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 4985): Caused by: android.view.InflateException:
Binary XML file line #2: Error inflating class <unknown>
E/AndroidRuntime( 4985): at
android.view.LayoutInflater.createView(LayoutInflater.java:513)
E/AndroidRuntime( 4985): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
E/AndroidRuntime( 4985): at
android.view.LayoutInflater.inflate(LayoutInflater.java:385)
E/AndroidRuntime( 4985): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 4985): at
android.view.LayoutInflater.inflate(LayoutInflater.java:276)
E/AndroidRuntime( 4985): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:
198)
E/AndroidRuntime( 4985): at
android.app.Activity.setContentView(Activity.java:1622)
E/AndroidRuntime( 4985): at
com.achie.test.mapssample.ItemDetailView.onCreate(ItemDetailView.java:
11)
E/AndroidRuntime( 4985): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
E/AndroidRuntime( 4985): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2459)
E/AndroidRuntime( 4985): ... 11 more
E/AndroidRuntime( 4985): Caused by:
java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 4985): at
com.google.android.maps.MapView.<init>(MapView.java:238)
E/AndroidRuntime( 4985): at
java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 4985): at
java.lang.reflect.Constructor.newInstance(Constructor.java:446)
E/AndroidRuntime( 4985): at
android.view.LayoutInflater.createView(LayoutInflater.java:500)
E/AndroidRuntime( 4985): ... 20 more
E/AndroidRuntime( 4985): Caused by:
java.lang.IllegalArgumentException: MapViews can only be created
inside instances of MapActivity.
E/AndroidRuntime( 4985): at
com.google.android.maps.MapView.<init>(MapView.java:282)
E/AndroidRuntime( 4985): at
com.google.android.maps.MapView.<init>(MapView.java:255)
E/AndroidRuntime( 4985): ... 24 more
Why am I getting this error and how can I resolve this and open a new
activity?
Also where can I find the source code for the google maps on android?
Thank you.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en