2

これは私のTabGroupActivityのコードです。ここで、特定のタブのいずれかでタブB->次に子アクティビティクラスCを起動します->次に任意のボタンをクリックすると再び子アクティビティクラスDを呼び出します

これで、クラスDから、戻るボタンを押すたびに、子アクティビティクラスCが再度リロードされます。クラスCから、戻るボタンを押すと、再び子アクティビティがリロードされます。

これに私を助けてください..私は前の活動をリロードしたくありません。

      public class TabGroupActivity extends ActivityGroup {

private ArrayList<String> mIdList;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (mIdList == null) mIdList = new ArrayList<String>();
}

/**
 * This is called when a child activity of this one calls its finish method. 
 * This implementation calls {@link LocalActivityManager#destroyActivity} on the child activity
 * and starts the previous activity.
 * If the last child activity just called finish(),this activity (the parent),
 * calls finish to finish the entire group.
 */
      @Override
       public void finishFromChild(Activity child) {
  LocalActivityManager manager = getLocalActivityManager();
  Log.i("Stack,finishFromChild", ""+mIdList);
  int index = mIdList.size()-1;

  if (index < 1) {
      finish();
      return;
  }

  manager.destroyActivity(mIdList.get(index), true);
  mIdList.remove(index); index--;
  String lastId = mIdList.get(index);
  Intent lastIntent = manager.getActivity(lastId).getIntent();
  lastIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
  Window newWindow = manager.startActivity(lastId, lastIntent);


  setContentView(newWindow.getDecorView());
   }

      /**
     * Starts an Activity as a child Activity to this.
      * @param Id Unique identifier of the activity to be started.
       * @param intent The Intent describing the activity to be started.
     * @throws android.content.ActivityNotFoundException.
       */
     public void startChildActivity(String Id, Intent intent) {     
  Window window = getLocalActivityManager().startActivity(Id,intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP));
  if (window != null) {
      mIdList.add(Id);
      setContentView(window.getDecorView()); 
  }    
   }

    /**
     * The primary purpose is to prevent systems before          android.os.Build.VERSION_CODES.ECLAIR
     * from calling their default KeyEvent.KEYCODE_BACK during onKeyDown.
    */

     /**
      * If a Child Activity handles KeyEvent.KEYCODE_BACK.
      * Simply override and add this method.
        */
     @Override
     public void  onBackPressed  () {
        int length = mIdList.size();
        if ( length > 1) {
        Log.i("Stack,onback", ""+mIdList);

        Activity current = getLocalActivityManager().getActivity(mIdList.get(length-1));
        Log.i("Activity in current",""+current);
         current.finish();

     }  
     else
     {
        if(length==1)
        {
          Activity current = getLocalActivityManager().getActivity(mIdList.get(length-1));
          Log.i("Activity in current",""+current);
          current.finish();
      }
  }
  }
4

0 に答える 0