BetterMan丶 2015-10-20 09:26 采纳率: 0%
浏览 2293

fragment间跳转时程序崩溃

我在一个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文件跟这个一样。

为什么会卡死,求大神解答

  • 写回答

3条回答 默认 最新

  • bdmh 移动开发领域优质创作者 2015-10-20 09:55
    关注

    你最好,看一下logcat的信息,找到错误原因以及错误代码文件和行数,调试便知

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型