【问题标题】:Problems using Bundle. Unable to find method?使用捆绑包的问题。找不到方法?
【发布时间】:2015-10-17 06:33:38
【问题描述】:

我正在尝试使用捆绑包。但是代码给了我一些错误.. paramBundle.open 返回错误:无法解析方法 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);
    }
}

【问题讨论】:

    标签: android methods bundle resolve


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      @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() 方法。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多