使用 Bundle 的问题。无法找到方法?

Problems using Bundle. Unable to find method?

我正在尝试使用捆绑包。但是代码给了我一些错误.. paramBundle.open returns 有一个错误:无法解析方法 open(),方法 close() 对我做同样的事情。 AnimationGetNewNumber 方法也无法解析。 我做错了什么?

 protected void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    setContentView(R.layout.activity_add_edit_animation);
    getIntent().getExtras();
    if (getIntent().getExtras().getInt("AEA_INT_ACTION", 0) == 0)
    {
        Bundle bundle= new Bundle(paramBundle);
        paramBundle.open();
        this.animationNumber = paramBundle.AnimationGetNewNumber();
        paramBundle.close();
    }
    for (;;)
    {
        this.gridView = ((GridView)findViewById(R.id.gridviewAddEdit));
        this.gridView.setChoiceMode(1);
        this.imageAdapter = new ImageAdapter(this, this.animationNumber);
        this.gridView.setAdapter(this.imageAdapter);
        this.gridView.setOnItemClickListener(this);
        this.gridView.setOnItemLongClickListener(this);
        return;
        this.animationNumber = getIntent().getExtras().getInt("AEA_INT_NUMBER", 0);
    }
}

Bundle 没有名为 open() 的方法,也没有名为 close() 的方法,也没有名为 AnimationGetNewNumber() 的方法。你不能调用不存在的方法。

您想从已保存的实例包中检索数据,然后在 activity 中使用以下方法。

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);

  this.animationNumber = savedInstanceState.AnimationGetNewNumber();//your code of retriving data from bundle

  Log.i("debug", "saved data: " + myString);
}

注意:bundle 实例没有 open() 和 close() 方法。