Issue
I have added a mapview to my xml layout with a node like so: contained inside a frame
<fragment
android:id="@+id/map"
android:layout_width="100dip"
android:layout_height="100dip"
android:name="com.google.android.gms.maps.MapFragment"/>
In my activity i have referenced it in the onCreate like so:
map = (MapView) findViewById(R.id.map);
with map defined in globally as MapView map;
06-02 14:51:12.357: E/AndroidRuntime(32368): FATAL EXCEPTION: main
06-02 14:51:12.357: E/AndroidRuntime(32368): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.KingNozzle/com.KingNozzle.KNAugmentedRealityActivity}: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to com.google.android.gms.maps.MapView
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.ActivityThread.access$600(ActivityThread.java:130)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.os.Looper.loop(Looper.java:137)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.ActivityThread.main(ActivityThread.java:4745)
06-02 14:51:12.357: E/AndroidRuntime(32368): at java.lang.reflect.Method.invokeNative(Native Method)
06-02 14:51:12.357: E/AndroidRuntime(32368): at java.lang.reflect.Method.invoke(Method.java:511)
06-02 14:51:12.357: E/AndroidRuntime(32368): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-02 14:51:12.357: E/AndroidRuntime(32368): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-02 14:51:12.357: E/AndroidRuntime(32368): at dalvik.system.NativeStart.main(Native Method)
06-02 14:51:12.357: E/AndroidRuntime(32368): Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to com.google.android.gms.maps.MapView
06-02 14:51:12.357: E/AndroidRuntime(32368): at com.KingNozzle.KNAugmentedRealityActivity.onCreate(KNAugmentedRealityActivity.java:129)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.Activity.performCreate(Activity.java:5008)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
06-02 14:51:12.357: E/AndroidRuntime(32368): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
06-02 14:51:12.357: E/AndroidRuntime(32368): ... 11 more
my whole layout looks like so:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<FrameLayout
android:id="@+id/arFrame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</FrameLayout>
<TextView
android:id="@+id/textViewLocation"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:text="no signal"
android:textAppearance="?android:attr/textAppearanceSmall" />
<fragment
android:id="@+id/map"
android:layout_width="100dip"
android:layout_height="100dip"
android:name="com.google.android.gms.maps.MapFragment">
</fragment>
<com.KingNozzle.Views.KNMultiDirectionalSlidingDrawer
xmlns:my="http://schemas.android.com/apk/res/com.KingNozzle"
android:id="@+id/drawer"
my:direction="topToBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
my:handle="@+id/handle"
my:content="@+id/content">
<include
android:id="@id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/empty_rel" />
<ImageView
android:id="@id/handle"
android:layout_width="wrap_content"
android:layout_height="40px"
android:src="@drawable/sliding_drawer_handle_bottom" />
</com.KingNozzle.Views.KNMultiDirectionalSlidingDrawer>
</RelativeLayout>
cant seem to find out why it thinks its a frame view
Solution
in you xml change MapFragment to SupportMapFragment
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
In your code
GoogleMap mMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
Answered By - prvn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.