2015-02-12 79 views
0

我有一個導航抽屜(MainMenu.class配置) 第一MainMenu加載NewRadioFragment然後我點擊按鈕在NewRadioFragment開始ViewPager,ViewPager有(PlayRadioFragment和BlogContentFragment)通過ViewPagerActivity(FragmentActivity)查看。Backbar導航在Actionbar

現在,我想要在操作欄中的後退按鈕從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(); 
    } 

當我點擊功能沒有完成

回答

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(); 
+0

第一!感謝您的回覆。我在onOptionsItemSelect中添加代碼? – 2015-02-12 02:22:28

+0

是的,我更新了片段 – Gatunox 2015-02-12 02:24:55

+0

我試過使用你的代碼。但給我NullPointerExeption,在線 意圖upIntent = NavUtils.getParentActivityIntent(this); 我顯示Log.i(「」,「TAG」+ upIntent);給價值空 – 2015-02-12 02:28:19

相關問題