當我從一個片段開了一個活動發生此錯誤。新活動包含viewPager
,我認爲錯誤是由新的活動,因爲當我一個代碼塊(viewPager.setAdapter(adapter))
區段,該錯誤會消失,我可以看到新的活動引起的。所以我認爲意圖不會造成任何問題。android.os.TransactionTooLargeException「viewPager.setAdapter(適配器)」
這裏是我的代碼片段
getActivity().startActivity(new Intent(getActivity(),five_oder.class));
新的活動主代碼
viewPager= (ViewPager) findViewById(R.id.oder_viewPafer);
tb= (PagerTabStrip) findViewById(R.id.order_tab);
TitleList = new ArrayList<String>();
fragmentList = new ArrayList<Fragment>();
TitleList.add("已完成訂單");
TitleList.add("未完成訂單");
fragmentList.add(new fragment_oder1());
fragmentList.add(new fragment_oder2());
MyFragmentAdapter adapter=new MyFragmentAdapter(getSupportFragmentManager(),fragmentList,TitleList);
viewPager.setAdapter(adapter);
適配器代碼
public class MyFragmentAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentList= new ArrayList<Fragment>();
private List<String> stringList=new ArrayList<String>();
public MyFragmentAdapter(FragmentManager fm, List<Fragment> fragmentList, List<String> stringList) {
super(fm);
this.fragmentList=fragmentList;
this.stringList =stringList;
Log.i("CHONG","MyFragmentAdapter construct");
}
@Override
public Fragment getItem(int position) {
Log.i("CHONG"," getItem");
return fragmentList.get(position);
}
@Override
public int getCount() {
Log.i("CHONG"," getItem");
return fragmentList.size();
}
@Override
public CharSequence getPageTitle(int position) {
return stringList.get(position);
}
}
錯誤日誌:
04-29 09:17:33.651 11798-11798/com.example.administrator.buyer E/JavaBinder:
!!! FAILED BINDER TRANSACTION !!!
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: Error reporting crash
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: android.os.TransactionTooLargeException
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at android.os.BinderProxy.transactNative(Native Method)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at android.os.BinderProxy.transact(Binder.java:496)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4124)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:89)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at com.loc.ai.uncaughtException(DynamicExceptionHandler.java:86)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
04-29 09:17:33.661 11798-11798/com.example.administrator.buyer E/AndroidRuntime: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
在此先感謝!
我已經上傳我的代碼,你的麻煩看!! – Yog
@Yog我已經更新了我的答案 –