Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8667575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:59:49+00:00 2026-06-12T17:59:49+00:00

I am Using View Pager to Display three Views. Filter,Streets,Around Each View is Defined

  • 0

I am Using View Pager to Display three Views.

"Filter","Streets","Around"

Each View is Defined by Fragment.

WHAT I WANT :
I want to Use Mapview Inside My FilterFragment.

WHAT I HAVE DONE :

I want to Use MapView Inside Filter Fragment but Could Not Able to Run Successfully. and Getting Log cate Error:

android.view.InflateException: Binary XML file line #33: Error inflating class com.google.android.maps.MapView

I have also Searched on Net and Stackoverflow about this Problem and Found the LINK and LINK but Could not able to Found this link Related to my Problem as i am using Fragment With ViewPager.

I have put my Code as Below.

Here is My Code for MainViewPager.java:

    package com.example.viewpageractivitydemo;

    import com.example.viewpageractivitydemo.viewpager.TitlePageIndicator;

    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.support.v4.view.ViewPager;
    import android.util.Log;

    public class MainViewPager extends FragmentActivity {

        TestFragmentAdapter adapter;
        ViewPager pager;

        @Override
        protected void onCreate(Bundle arg0) {
            // TODO Auto-generated method stub
            super.onCreate(arg0);
            Log.i("MainViewPager","Inside Oncreate");
            setContentView(R.layout.mainviewpager);
            pager = (ViewPager) findViewById(R.id.pager);

            adapter = new TestTitleFragmentAdapter(getSupportFragmentManager());
            pager.setAdapter(adapter);

            TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.indicator);
            indicator.setViewPager(pager);
            pager.setCurrentItem(1);

        }

        @Override
        protected void onResume() {
            // TODO Auto-generated method stub
            super.onResume();

    //      pager.setCurrentItem(1);
        }

    }

Here is Code for TestFragmentAdapter.java

package com.example.viewpageractivitydemo;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

public class TestFragmentAdapter extends FragmentPagerAdapter {

    protected static final String[] CONTENT = new String[] { "Filter",
            "Streets", "Around" };
    public String TAG = "TestFragmentAdapter";
    private int mCount = CONTENT.length;

    public TestFragmentAdapter(FragmentManager fm) {
        super(fm);
        // TODO Auto-generated constructor stub
    }

    @Override
    public Fragment getItem(int position) {
        // TODO Auto-generated method stub
        Log.i(TAG, "Inside getItemMethod with position " + position);

        if (position == 0) {
            Log.i("TestFragmentAdapter","Inside if Condition");
            return FilterFragment.newInstance(position);
        } else if (position == 1) {
            return StreetsFragment.newInstance(position);
        } else if (position == 2) {
            return AroundFragment.newInstance(position);
        } else {
            return null;
        }
        // return MainFragment.newInstance(CONTENT[position % CONTENT.length]);

    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mCount;
    }

    public void setCount(int count) {
        if (count > 0 && count <= 10) {
            mCount = count;
            notifyDataSetChanged();
        }
    }

}

Here is My Code for FilterFragment.java:

package com.example.viewpageractivitydemo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class FilterFragment extends Fragment {

    /*
     * @Override protected Class<? extends Activity> getActivityClass() { //
     * TODO Auto-generated method stub return MyFilterActivity.class; }
     */

    public static Fragment newInstance(int position) {

        Log.i("FilterFragment","Inside New Instasnce");
        FilterFragment filterFragment = new FilterFragment();
        return filterFragment;

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        Log.i("FilterFragment","Inside OcCreateView");
        View view = inflater.inflate(R.layout.filter, null);
        return view;
    }

}

Here is My Code for filter.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#C6CDD4"
    android:gravity="center"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#93A4BA"
            android:gravity="center" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_margin="5dp"
                android:gravity="center"
                android:text="Where Am I"
                android:textColor="#ffffff"
                android:textSize="18dp"
                android:textStyle="bold" >
            </TextView>
        </LinearLayout>

        <com.google.android.maps.MapView
            android:id="@+id/whereami_mapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:apiKey="0-PaH6rk7RKrZSMd_lqdrZi6FazYyIlX5r6YFyA"
            android:clickable="true" />

        <!--
             <com.google.android.maps.MapView
            android:id="@+id/whereami_mapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:apiKey="0-PaH6rk7RKrZSMd_lqdrZi6FazYyIlX5r6YFyA" />



        -->
    </LinearLayout>

</LinearLayout>

Please Can anyone Suggest Me Answer to Solve My Problem. I have Spent many Hours on this. Still not getting any Idea about my Question.
Thnks in Advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:59:51+00:00Added an answer on June 12, 2026 at 5:59 pm

    You can use LocalActivityManager to host a Activity inside a fragment. It is a deprecated class, but it offers the simplest solution.

    Here is the code for a fragment (MyFilterFragment in your code). YourMapActivity is a basic activity that extends MapActivity.

    public class MapFragment extends Fragment {
        private static final String KEY_STATE_BUNDLE = "localActivityManagerState";
    
        private LocalActivityManager mLocalActivityManager;
    
        protected LocalActivityManager getLocalActivityManager() {
            return mLocalActivityManager;
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            Bundle state = null;
            if (savedInstanceState != null) {
                state = savedInstanceState.getBundle(KEY_STATE_BUNDLE);
            }
    
            mLocalActivityManager = new LocalActivityManager(getActivity(), true);
            mLocalActivityManager.dispatchCreate(state);
        }
    
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
                //This is where you specify you activity class
            Intent i = new Intent(getActivity(), YourMapActivity.class); 
            Window w = mLocalActivityManager.startActivity("tag", i); 
            View currentView=w.getDecorView(); 
            currentView.setVisibility(View.VISIBLE); 
            currentView.setFocusableInTouchMode(true); 
            ((ViewGroup) currentView).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
            return currentView;
        }
    
        @Override
        public void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
            outState.putBundle(KEY_STATE_BUNDLE,
                    mLocalActivityManager.saveInstanceState());
        }
    
        @Override
        public void onResume() {
            super.onResume();
            mLocalActivityManager.dispatchResume();
        }
    
        @Override
        public void onPause() {
            super.onPause();
            mLocalActivityManager.dispatchPause(getActivity().isFinishing());
        }
    
        @Override
        public void onStop() {
            super.onStop();
            mLocalActivityManager.dispatchStop();
        }
    
        @Override
        public void onDestroy() {
            super.onDestroy();
            mLocalActivityManager.dispatchDestroy(getActivity().isFinishing());
        }
    }
    

    Edit: Since this answer was posted, Google has released Google Maps Android API with fragment support with an official MapFragment class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using $route['(:any)'] = 'pages/view/$1'; and I want to use other controllers in my
I using coda slider in my page. View it here: http://www.ndoherty.com/demos/coda-slider/1.1.1/ Each tab causes
I am using a android.support.v4.view.ViewPager and wish to page through its views quickly. Currently,
In my ASP.net MVC App (using Razor views) I have a ProductDetails view. This
i am using the views 2 module. i have a view that gets a
I'm trying to create a page by using view 2. This page list all
I'm developing a single-page view for a resource that contains multiple nested resources. Using
I'm using Spree 0.70. In my home page view, I have the following to
I am using a stored procedure to make page-navigation when I view a list
Using ASP MVC and Entity Framework. In the view, you have a page declaration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.