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

  • Home
  • SEARCH
  • 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 9232295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:16:49+00:00 2026-06-18T06:16:49+00:00

I’m using a ListView which drives a detail view. The List view and Detail

  • 0

I’m using a ListView which drives a detail view. The List view and Detail view have their own activities. The detail view displays a map in a smaller layout. The code for map fragment is as follows:

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="150dp" android:id="@+id/details_emap_container"
        android:background="@drawable/back_rounded_rectangle_border_black"
        android:padding="2dp"
        >
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:tag="details_map_short"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              class="com.google.android.gms.maps.SupportMapFragment"
              />
    <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/rightArrowMap" android:src="@drawable/right_arrow_black"
            android:layout_alignParentRight="true" android:layout_centerVertical="true"
            android:layout_marginRight="10dp"/>
</RelativeLayout>

The first time I click on a list item when in a two pane layout on a tablet, it works fine. But on subsequently selecting any other list item, following error is thrown:

android.view.InflateException: Binary XML file line #159: Error inflating class fragment
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:688)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
        at com.xxxx.android.activity.fragments.EventDetailFragment.onCreateView(EventDetailFragment.java:97)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
        at android.os.Handler.handleCallback(Handler.java:587)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:132)
        at android.app.ActivityThread.main(ActivityThread.java:4123)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:491)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.IllegalArgumentException: Binary XML file line #159: Duplicate id 0xffffffff, tag details_map_short, or parent id 0x0 with another fragment for com.google.android.gms.maps.SupportMapFragment
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:660)
        ... 22 more

The EventDetailFragment looks like this:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    Log.e(TAG, "onCreateView was called!");
    // If activity recreated (such as from screen rotate), restore
    // the previous article selection set by onSaveInstanceState().
    // This is primarily necessary when in the two-pane layout.
    if (savedInstanceState != null) {
        mCurrentPosition = savedInstanceState.getInt(ARG_POSITION);
        mCurrEventId = savedInstanceState.getString(EVENT_ID);
    }

    // Inflate the layout for this fragment
    detailsView = inflater.inflate(R.layout.fragment_event_detail, container, false);

    mMapFragment = (SupportMapFragment)getFragmentManager().findFragmentByTag(MAP_FRAGMENT_TAG);

    // We can't be guaranteed that the map is available because Google Play services might
    // not be available.
    //setUpMapIfNeeded();  //do this later in onStart

    return detailsView;

}

The code in List activity to display the detail activity or fragment when an item is slected:

@Override
public void onItemSelected(int index) {
    Log.d(TAG, "Item Selected is : " + index);
    if(findViewById(R.id.event_details_container) != null) {
        // In two-pane mode, show the detail view in this activity by
        // adding or replacing the detail fragment using a
        // fragment transaction.
        Log.d(TAG, "Two pane layout navigation executed");
        Bundle arguments = new Bundle();
        arguments.putInt(EventDetailFragment.ARG_POSITION, index);
        EventDetailFragment fragment = new EventDetailFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.event_details_container, fragment).commit();
    }
    else {
        // In single-pane mode, simply start the detail activity
        // for the selected item ID.
        Log.d(TAG, "Single pane layout navigation - creating new Activity to display!");
        getSupportFragmentManager().executePendingTransactions();
        Intent detailIntent = new Intent(this, EventDetailActivity.class);
        detailIntent.putExtra(EventDetailFragment.ARG_POSITION, index);
        startActivity(detailIntent);
    }

}

I’m not able to figure out why this doesn’t work when in two pane layout? And why only the MapFragment seems to throw the error? This was all working just fine until I added the SupportMapFragment. Any help/ideas will be appreciated!

PS: The code has to be supported for API level 10 onwards.

  • 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-18T06:16:50+00:00Added an answer on June 18, 2026 at 6:16 am

    I finally found the correct fix for this. Since I was using maps in a Fragment in a two pane layout; I had to programmatically construct the map instead of defining in xml. This is demonstrated in the maps example ProgrammaticDemoActivity in android SDK (googleplayservices). Below is excerpt from the example, this is called from onCreateView when called from a Fragment (or onCreate if you’re calling from an Activity):

    // It isn't possible to set a fragment's id programmatically so we set a tag instead and
    // search for it using that.
    mMapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentByTag(MAP_FRAGMENT_TAG);
    
    // We only create a fragment if it doesn't already exist.
    if (mMapFragment == null) {
        // To programmatically add the map, we first create a SupportMapFragment.
        mMapFragment = SupportMapFragment.newInstance();
    
        // Then we add it using a FragmentTransaction.
        FragmentTransaction fragmentTransaction = getSupportFragmentManager()
                .beginTransaction();
        fragmentTransaction.add(android.R.id.content, mMapFragment, MAP_FRAGMENT_TAG);
        fragmentTransaction.commit();
    }
    

    The reason this is so because by default the map fragment will have it’s own life cycle and not tied to the view life cycle. So if you define it in xml the map fragment is not destroyed but the view is destroyed. This causes an error when you try to inflate the fragment again since the map is already present! See this for more info: https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment

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

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.