简体   繁体   English

测试ViewPager上的ViewPager“TransactionTooLargeException”

[英]ViewPager “TransactionTooLargeException” on test ViewPager

I'm implementing ViewPager for the first time and I'm facing some issue because I get following error: 我是第一次实现ViewPager而且我遇到了一些问题,因为我收到以下错误:

06-20 10:40:51.366 11377-11377/com.example.ruelas.elite E/AndroidRuntime: Error reporting crash
                                                                      android.os.TransactionTooLargeException: data parcel size 26485896 bytes
                                                                          at android.os.BinderProxy.transactNative(Native Method)
                                                                          at android.os.BinderProxy.transact(Binder.java:503)
                                                                          at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4425)
                                                                          at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:90)
                                                                          at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                                                                          at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)

Im not doing anything fancy with ViewPager but I'm not able to make it work, this is the Activity thats running it: 我没有对ViewPager做任何想象,但我无法使它工作,这是运行它的Activity:

package com.example.ruelas.elite;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class setup extends AppCompatActivity {
ViewPager vpSetup;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setup);
    vpSetup = (ViewPager)findViewById(R.id.vpSetup);
    vpSetup.setAdapter(new adapterSetup(getSupportFragmentManager()));
}
}

The adapterSetup Class: adapterSetup类:

package com.example.ruelas.elite;

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

public class adapterSetup extends FragmentPagerAdapter {
String [] titulos = new String[]{"Modalidad", "Temas"};
public adapterSetup(FragmentManager fm) {
    super(fm);
}
@Override
public Fragment getItem(int position) {
    switch (position){
        case 0:
            Log.d("case0","case0");
            return new fragmentModalidad();
        case 1:
            return new fragmentTemas();
        default:
            return null;
    }
}
@Override
public int getCount() {
    return titulos.length;
}
@Override
public CharSequence getPageTitle(int position) {
    return titulos[position];
}
}

My gradle since I think it may have something to do with this: 我认为这可能与此有关:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.example.ruelas.elite"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.0.0'
}

One of the fragments (they are just XMLS with a Large Text in them: 其中一个片段(它们只是带有大文本的XMLS:

package com.example.ruelas.elite;

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Ruelas on 20/06/2016.
 */
public class fragmentModalidad extends Fragment{
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragmentmodalidad, container, false);
    }
}

Thank you in advance, feel free to ask if I missed any necessary information. 提前谢谢,随时问我是否错过了任何必要的信息。

My bad guys, the other class inflater was not calling the correct constructor, it was: 我的坏人,其他类inflater没有调用正确的构造函数,它是:

return inflater.inflate(R.layout.fragmentmodalidad, container);

When: 什么时候:

return inflater.inflate(R.layout.fragmentmodalidad, container, false);

was needed 需要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM