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 7947113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:20:22+00:00 2026-06-04T01:20:22+00:00

Trying to change fragment width when user rotate device to landscape mode That is

  • 0

Trying to change fragment width when user rotate device to landscape mode

That is my fragment:

    <fragment
        android:id = "@+id/menu"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        class="myPackage.MenuFragment" />

And that is my onConfigurationChanged method:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setContentView(R.layout.main);
    findViewById(R.id.menu).getLayoutParams().width = (int) (getWindowManager()
            .getDefaultDisplay().getWidth());
}

But when I rotate device the output is crash:

05-14 03:00:51.379: E/AndroidRuntime(3117): FATAL EXCEPTION: main
05-14 03:00:51.379: E/AndroidRuntime(3117):
android.view.InflateException: Binary XML file line #13: Error
inflating class fragment 05-14 03:00:51.379: E/AndroidRuntime(3117):
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:582)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:621) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
android.view.LayoutInflater.inflate(LayoutInflater.java:407) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
android.view.LayoutInflater.inflate(LayoutInflater.java:276) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.app.Activity.setContentView(Activity.java:1654) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
softserveinc.dbyst.reveal.Reveal_prototypeActivity.onConfigurationChanged(Reveal_prototypeActivity.java:71)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:4153)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:4246)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2215)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.os.Handler.dispatchMessage(Handler.java:99) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
android.os.Looper.loop(Looper.java:143) 05-14 03:00:51.379:
E/AndroidRuntime(3117): at
android.app.ActivityThread.main(ActivityThread.java:4914) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
java.lang.reflect.Method.invokeNative(Native Method) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
java.lang.reflect.Method.invoke(Method.java:521) 05-14 03:00:51.379:
E/AndroidRuntime(3117): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-14
03:00:51.379: E/AndroidRuntime(3117): at
dalvik.system.NativeStart.main(Native Method) 05-14 03:00:51.379:
E/AndroidRuntime(3117): Caused by: java.lang.IllegalArgumentException:
Binary XML file line #13: Duplicate id 0x7f050001, tag null, or parent
id 0x0 with another fragment for myPackage.MenuFragment 05-14
03:00:51.379: E/AndroidRuntime(3117): at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:275)
05-14 03:00:51.379: E/AndroidRuntime(3117): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
05-14 03:00:51.379: E/AndroidRuntime(3117): … 19 more

What i’v done wrong ?

  • 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-04T01:20:24+00:00Added an answer on June 4, 2026 at 1:20 am

    Yes your setcontentview crashes because you got the fragment defined in XML. You got a couple of options here (that I know of, I’m not a pro on this issue 😉 ). You can put a FrameLayout where the fragment is and then add the fragment with a replace transaction:

            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    
            fragmentTransaction.replace(R.id.frameLayout_container, yourFragmentObject);
    
            fragmentTransaction.commit();
    

    Alternatively you can test if setRetainInstance(true) will work.

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

Sidebar

Related Questions

I'm trying to change the width of a JQuery dialog after it has been
I trying to change a website that is already up and running. I have
I'm trying change an input mask for textbox when the the check box has
I´m trying to change a spring jsp example to use freemarker. I changed all
im trying to change font globally for whole application, the problem is, i am
I am trying to change the bindingRedirect element at install time by using the
I'm trying to change a Button's Click property/event when a DataTrigger is triggered but
I am trying to change the Background Color of the ParentGrid when the child
I am trying to change the class of a element with Javascript using the
I'm trying to change the description of an existing SharePoint group which shouldn't be

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.