android事务处理异常太大

时间:2016-11-13 14:59:02

标签: android xml

我有一个对片段开放的活动,两个片段都包含无线电组,其中包含可绘制的图像作为按钮。当活动打开时,返回上一个活动并说事务太大异常。这个异常因为它没有正确加载可选择单选按钮。

Residential_Commercial_Activity java:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_residential__commercial_);
    Firstopenfragment();
    SetToolbar();
    TypeCasting();

    //FOR BACK BUTTON ENABLED
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mNextActivity.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //get data from map activity and also from this activity which button is clicked in the form of string and pass previous data and this activity data to next activity which is "Upload_Property_Activity"

            Intent next = new Intent(Residential_Commercial_Activity.this, Upload_Property_Activity.class);
            startActivity(next);
        }
    });


    mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            RelativeLayout rl = (RelativeLayout) findViewById(R.id.Replace);

            if (checkedId == R.id.Commercial) {
                //calling fragment  Builder_Broker_Fragment
                CommercialFragment frag = new CommercialFragment();
                FragmentManager manager = getFragmentManager();
                FragmentTransaction transaction = manager.beginTransaction();
                transaction.replace(R.id.Replace, frag, "Commercial");


                //  transaction.replace(R.id.frag1,frag);
                transaction.commit();
                Toast.makeText(getApplication(), "clicked", Toast.LENGTH_SHORT).show();

            } else if (checkedId == R.id.Residential) {

                ResidentialFragment frag = new ResidentialFragment();
                FragmentManager manager = getFragmentManager();
                FragmentTransaction transaction = manager.beginTransaction();
                transaction.replace(R.id.Replace, frag, "Residential");
                transaction.commit();
            }

        }
    });


}

private void Firstopenfragment() {

    ResidentialFragment frag = new ResidentialFragment();
    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.Replace, frag, "Residential");
    transaction.commit();

}

residential_commercial xml:

    

    <include
        android:id="@+id/app_bar"
        layout="@layout/appbartransparent"></include>

    <ImageView
        android:id="@+id/Backgroundimage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="centerCrop"
        android:src="@mipmap/background" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#2E7D32"
        android:text="Next"
        android:layout_gravity="bottom"
        android:id="@+id/NextActivity" />



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="50dp"
        android:background="#FFFFFF"
        android:orientation="vertical"
        android:layout_marginBottom="60dp">


        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="90dp"
            android:layout_marginStart="90dp"
            android:layout_marginTop="20dp">


            <ImageView
                android:layout_width="150dp"
                android:layout_height="100dp"
                android:layout_gravity="center"
                android:background="@drawable/residential" />
        </LinearLayout>


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp"
            android:text="@string/Gotit"
            android:textSize="23dp" />

        <RadioGroup
            android:id="@+id/RadioButton"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp"
            android:checkedButton="@+id/first"
            android:orientation="horizontal"
            android:weightSum="1">


            <RadioButton
                android:id="@+id/Residential"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/for_sell"
                android:checked="false"
                android:button="@null"/>

            <RadioButton
                android:id="@+id/Commercial"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/Residential"
                android:background="@drawable/commercialdrawable"
                android:button="@null"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp" />


        </RadioGroup>

        <RelativeLayout
            android:id="@+id/Replace"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginRight="10dp">


        </RelativeLayout>


    </LinearLayout>

</FrameLayout>
<fragment
    android:id="@+id/fragment_navigation1"
    android:name="com.example.asad.homebuyerproject.NavigationBar"
    android:layout_width="@dimen/navigationdrawerwidth"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:layout="@layout/fragment_navigation"
    tools:layout="@layout/fragment_navigation" />

此活动打开为片段,其中一个在活动打开时打开的布局为:

fragment_residential:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
tools:context="com.example.asad.homebuyerproject.ResidentialFragment">


<RadioGroup
    android:id="@+id/ReplaceAreaCommercial"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="10dp"
    android:background="#FFFFFF">


    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/hosteldrawable"
        android:button="@null" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Residential"
        android:background="@drawable/housedrawable"
        android:button="@null" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Residential"
        android:background="@drawable/builderfloor"
        android:button="@null" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Residential"
        android:background="@drawable/penthousedrawable"
        android:button="@null" />


</RadioGroup>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="150dp"
    android:layout_marginStart="150dp"

    >

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/flatdrawable"
            android:button="@null" />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/villadrawable"
            android:button="@null"

            />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/studioaprtment"
            android:button="@null" />


    </RadioGroup>

</RelativeLayout>

logcat的:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.example.asad.homebuyerproject, PID: 4082
              java.lang.StackOverflowError: stack size 8MB
                  at android.content.res.XmlBlock.newParser(XmlBlock.java:71)
                  at android.content.res.Resources.loadXmlResourceParser(Resources.java:2672)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2467)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
                  at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
                  at android.content.res.Resources.loadDrawable(Resources.java:2381)
                  at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                  at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
                  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
                  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
                at android.graphics.drawable.Drawable.createFromXml(Drawa
     I/art: WaitForGcToComplete blocked for 26.116ms for cause Alloc
     I/art: WaitForGcToComplete blocked for 25.978ms for cause Alloc
     I/art: WaitForGcToComplete blocked for 25.225ms for cause Alloc
     I/art: WaitForGcToComplete blocked for 25.021ms for cause Alloc
     D/Error: ERR: exClass=java.lang.StackOverflowError
     D/Error: ERR: exMsg=stack size 8MB
     D/Error: ERR: file=XmlBlock.java
     D/Error: ERR: class=android.content.res.XmlBlock
     D/Error: ERR: method=newParser line=71
      I/art: Background sticky concurrent mark sweep GC freed 2(800KB)                                                                   AllocSpace objects, 0(0B) LOS objects, 0% free, 91MB/92MB, paused 7.924ms total 10.023ms
      I/art: Alloc partial concurrent mark sweep GC freed 34(2608B)                AllocSpace objects, 1(21MB) LOS objects, 18% free, 70MB/86MB, paused 206us total 22.998ms
      D/Error: ERR: stack=java.lang.StackOverflowError: stack size 8MB
         at android.content.res.XmlBlock.newParser(XmlBlock.java:71)
         at android.content.res.Resources.loadXmlResourceParser(Resources.java:2672)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2467)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
         at android.content.res.Resources.loadDrawableForCookie(Resources.java:2469)
         at android.content.res.Resources.loadDrawable(Resources.java:2381)
         at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
         at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:182)
         at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:127)
         at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1128)
         at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1032)
        at android.content.res.Resources.loadDrawableForCookie(Res
      D/Error: ERR: TOTAL BYTES WRITTEN: 15842836
     E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!
       E/AndroidRuntime: Error reporting crash
              android.os.TransactionTooLargeException
                  at android.os.BinderProxy.transactNative(Native Method)
                  at android.os.BinderProxy.transact(Binder.java:496)
          Application terminated.

要打开的片段是: all are radio buttons with drawables

0 个答案:

没有答案