我在一个Activity中加载了三个fragment,每个fragment里有几张图片,从一个fragment跳转到另一个fragment时程序就没反应了,直接崩溃,但是如果把图片减少或者全部移除,跳转就完全没有问题,请问这个问题如何解决?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpMenu();
changeFragment(new JingdianFragment() );
setListener();
}
private void setUpMenu() {
leftMenu = (Button) findViewById(R.id.title_bar_left_menu);
text1 = (TextView) findViewById(R.id.text1);
text2 = (TextView) findViewById(R.id.text2);
text3 = (TextView) findViewById(R.id.text3);
text4 = (TextView) findViewById(R.id.text4);
topFrameLayout = (FrameLayout) findViewById(R.id.topFrameLayout);
text1.getBackground().setAlpha(200);
text2.getBackground().setAlpha(200);
text3.getBackground().setAlpha(200);
text4.getBackground().setAlpha(200);
topFrameLayout.getBackground().setAlpha(130);
// attach to current activity;
resideMenu = new ResideMenu(this);
resideMenu.setBackground(R.drawable.menu_background);
resideMenu.attachToActivity(this);
resideMenu.setMenuListener(menuListener);
// valid scale factor is between 0.0f and 1.0f. leftmenu'width is
// 150dip.
resideMenu.setScaleValue(0.6f);
// 禁止使用右侧菜单
resideMenu.setDirectionDisable(ResideMenu.DIRECTION_RIGHT);
// create menu items;
itemUserInfo = new ResideMenuItem(this, R.drawable.icon_home, "个人信息");
itemCanTour = new ResideMenuItem(this, R.drawable.icon_home, "会旅游");
itemOrder = new ResideMenuItem(this, R.drawable.icon_home, "我的订单");
itemShare = new ResideMenuItem(this, R.drawable.icon_home, "个人分享");
itemHelp = new ResideMenuItem(this, R.drawable.icon_settings, "帮助");
resideMenu.addMenuItem(itemUserInfo, ResideMenu.DIRECTION_LEFT);
resideMenu.addMenuItem(itemCanTour, ResideMenu.DIRECTION_LEFT);
resideMenu.addMenuItem(itemOrder, ResideMenu.DIRECTION_LEFT);
resideMenu.addMenuItem(itemShare, ResideMenu.DIRECTION_LEFT);
resideMenu.addMenuItem(itemHelp, ResideMenu.DIRECTION_LEFT);
private void changeFragment(Fragment targetFragment) {
resideMenu.clearIgnoredViewList();
getSupportFragmentManager().beginTransaction()
.replace(R.id.main_fragment, targetFragment, "fragment")
.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
}
以上是mainActivity中的主要方法,下面是xml文件的布局
<?xml version="1.0" encoding="utf-8"?>
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_1"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_2"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_3"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_4"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_5"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_6"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/jingdian_7"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
</LinearLayout>
</ScrollView>
其余两个XML文件跟这个一样。
为什么会卡死,求大神解答