Google MapView in Sliding View
<p>I downloaded the example <a href="http://developer.android.com/training/implementing-navigation/index.html" rel="nofollow">Implementing Effective Navigation</a> from Google, but when I tried to insert a Google MapView in my project it failed. Could someone help me?</p>

<p>I have tried another simple SliderProject called <a href="http://code.google.com/p/android-mt-tutorials/source/browse/#svn%2Ftags%2FSimpleViewPager-1" rel="nofollow">SimpleViewPager</a> and added in one layout a MapFragment and get this LogCat</p>

<pre><code>02-14 17:30:24.375: D/libEGL(26121): loaded /system/lib/egl/libEGL_mali.so
02-14 17:30:24.390: D/libEGL(26121): loaded /system/lib/egl/libGLESv1_CM_mali.so
02-14 17:30:24.405: D/libEGL(26121): loaded /system/lib/egl/libGLESv2_mali.so
02-14 17:30:24.415: D/(26121): Device driver API match
02-14 17:30:24.415: D/(26121): Device driver API version: 10
02-14 17:30:24.415: D/(26121): User space API version: 10 
02-14 17:30:24.420: D/(26121): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
02-14 17:30:24.455: D/OpenGLRenderer(26121): Enabling debug mode 0
02-14 17:32:22.075: D/AndroidRuntime(26121): Shutting down VM
02-14 17:32:22.075: W/dalvikvm(26121): threadid=1: thread exiting with uncaught exception (group=0x411332a0)
02-14 17:32:22.085: E/AndroidRuntime(26121): FATAL EXCEPTION: main
02-14 17:32:22.085: E/AndroidRuntime(26121): java.lang.NullPointerException
02-14 17:32:22.085: E/AndroidRuntime(26121):    at fhtw.dh.mapslider.MainMapSliderActivity$MyPagerAdapter.instantiateItem(MainMapSliderActivity.java:73)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:801)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.support.v4.view.ViewPager.populate(ViewPager.java:992)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.support.v4.view.ViewPager$3.run(ViewPager.java:237)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.view.Choreographer.doFrame(Choreographer.java:524)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.os.Handler.handleCallback(Handler.java:615)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.os.Handler.dispatchMessage(Handler.java:92)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.os.Looper.loop(Looper.java:137)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at android.app.ActivityThread.main(ActivityThread.java:4898)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at java.lang.reflect.Method.invokeNative(Native Method)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at java.lang.reflect.Method.invoke(Method.java:511)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
02-14 17:32:22.085: E/AndroidRuntime(26121):    at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>This is the whole MainMapSliderActivity:</p>

<pre><code>package fhtw.dh.mapslider;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;

public class MainMapSliderActivity extends Activity {

private GoogleMap map;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main_map_slider);

            MyPagerAdapter adapter = new MyPagerAdapter();
            ViewPager myPager = (ViewPager) findViewById(R.id.myfivepanelpager);
            myPager.setAdapter(adapter);
            myPager.setCurrentItem(2);
    }

    public void farLeftButtonClick(View v)
    {
            Toast.makeText(this, "Far Left Button Clicked", Toast.LENGTH_SHORT).show(); 

    }

    public void farRightButtonClick(View v)
    {
            Toast.makeText(this, "Far Right Elephant Button Clicked", Toast.LENGTH_SHORT).show(); 

    }

    private class MyPagerAdapter extends PagerAdapter {

            public int getCount() {
                    return 5;
            }

            public Object instantiateItem(View collection, int position) {

                    LayoutInflater inflater = (LayoutInflater) collection.getContext()
                                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                    int resId = 0;
                    switch (position) {
                    case 0:
                            resId = R.layout.farleft;
                            break;
                    case 1:
                            resId = R.layout.left;
                            break;
                    case 2:
                            resId = R.layout.middle;
                            break;
                    case 3:
                            resId = R.layout.right;
                            break;
                    case 4:
                            resId = R.layout.fahrright;
                            map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map1)).getMap();
                            break;
                    }

                    View view = inflater.inflate(resId, null);

                    ((ViewPager) collection).addView(view, 0);

                    return view;
            }

            @Override
            public void destroyItem(View arg0, int arg1, Object arg2) {
                    ((ViewPager) arg0).removeView((View) arg2);

            }

            @Override
            public void finishUpdate(View arg0) {
                    // TODO Auto-generated method stub

            }

            @Override
            public boolean isViewFromObject(View arg0, Object arg1) {
                    return arg0 == ((View) arg1);

            }

            @Override
            public void restoreState(Parcelable arg0, ClassLoader arg1) {
                    // TODO Auto-generated method stub

            }

            @Override
            public Parcelable saveState() {
                    // TODO Auto-generated method stub
                    return null;
            }

            @Override
            public void startUpdate(View arg0) {
                    // TODO Auto-generated method stub

            }

    }
}
</code></pre>

<p>And my layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;
    &lt;TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:text="@string/farright_text" /&gt;

    &lt;ImageButton android:id="@+id/button2"
            android:layout_height="wrap_content" android:text="I am a Button. Click Me. "
            android:onClick="farRightButtonClick" android:src="@drawable/ic_launcher"
            android:adjustViewBounds="true" android:scaleType="fitXY"
            android:layout_width="wrap_content"&gt;&lt;/ImageButton&gt;

   &lt;fragment
        android:id="@+id/map1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        class="com.google.android.gms.maps.MapFragment"/&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>Manifest File:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fhtw.dh.mapslider"
android:versionCode="1"
android:versionName="1.0" &gt;

&lt;permission
  android:name="fhtw.dh.mapslider.permission.MAPS_RECEIVE"
  android:protectionLevel="signature"/&gt;
&lt;uses-permission android:name="fhtw.dh.mapslider.permission.MAPS_RECEIVE"/&gt;

&lt;uses-permission android:name="android.permission.INTERNET"/&gt;
&lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt;
&lt;!-- External storage for caching. --&gt;
&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
&lt;!-- My Location --&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
&lt;!-- Maps API needs OpenGL ES 2.0. --&gt;
&lt;uses-feature
  android:glEsVersion="0x00020000"
  android:required="true"/&gt;

&lt;uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" /&gt;

&lt;application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" &gt;
    &lt;!-- You must insert your own Google Maps for Android API v2 key in here. --&gt;
    &lt;meta-data
      android:name="com.google.android.maps.v2.API_KEY"
      android:value="AIzaSyD5h0TQNBvRso8S-gd89Bt2-YI22F6tM-g"/&gt;
    &lt;activity
        android:name="fhtw.dh.mapslider.MainMapSliderActivity"
        android:label="@string/app_name" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
  &lt;/application&gt;
&lt;/manifest&gt;
</code></pre>
