在Actionbar中返回导航

时间:2015-02-12 02:14:50

标签: android android-fragments

我有一个导航抽屉(MainMenu.class配置) 首先MainMenu加载NewRadioFragment然后我点击NewRadioFragment按钮开始ViewPager,ViewPager有(PlayRadioFragment和BlogContentFragment)通过ViewPagerActivity(FragmentActivity)查看。

现在,我希望Actionbar中的Back Button从PlayRadioFragment返回到NewRadioFragment。

我需要帮助!

更新

private void setImageView(ImageView src, View rootView) {
        image_disk = (ImageView) rootView.findViewById(R.id.base);
        new Thread(new Runnable() {
            @Override
            public void run() {
                final Bitmap bimit = Utils.loadBitmap(image_url);
                image_disk.post(new Runnable() {
                    @Override
                    public void run() {
                        image_disk.setImageBitmap(bimit);
                        prg_loading.setVisibility(View.GONE);
                        tv_loading.setVisibility(View.GONE);
                        btnPlay.setVisibility(View.VISIBLE);
                    }
                });
            }
        }).start();
    }

当我点击功能时没完成

1 个答案:

答案 0 :(得分:0)

你试过这个吗?

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:

    Intent upIntent = NavUtils.getParentActivityIntent(this);
    if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
        // This activity is NOT part of this app's task, so create a new task
        // when navigating up, with a synthesized back stack.
        TaskStackBuilder.create(this)
                // Add all of this activity's parents to the back stack
                .addNextIntentWithParentStack(upIntent)
                // Navigate up to the closest parent
                .startActivities();
    } else {
        // This activity is part of this app's task, so simply
        // navigate up to the logical parent activity.
        NavUtils.navigateUpTo(this, upIntent);
    }
    return true;
 }
  return super.onOptionsItemSelected(item);
}

或 试试这个

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

或 致电

Finish();