ViewPager" TransactionTooLargeException"在测试ViewPager上

时间:2016-06-20 17:25:30

标签: android android-fragments android-viewpager

我是第一次实施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)

我没有对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()));
}
}

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];
}
}

我认为这可能与此有关:

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'
}

其中一个片段(它们只是带有大文本的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);
    }
}

提前感谢您,请随时询问我是否遗漏了任何必要的信息。

1 个答案:

答案 0 :(得分:6)

我的坏人,其他类的inflater没有调用正确的构造函数,它是:

OR nombre_ciudad LIKE '%da%';

当:

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

需要