2

我是新学习者

当我从我买的书中复制练习代码时,它告诉我 putExtra 没有为 Bundle 定义

我可以改用 putLong 吗?或者是什么?

public class ReminderEditActivity extends FragmentActivity {
@Override
public void onCreate (Bundle savedInstanceState) {
    super.onCreate (savedInstanceState);
    setContentView (R.layout.reminder_edit_activity);
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(ReminderEditFragment.DEFAULT_EDIT_FRAGMENT_TAG);
    if (fragment == null) {
    fragment = new ReminderEditFragment();
    Bundle args = new Bundle();
    args.putExtra(ReminderProvider.COLUMN_ROWID, getIntent().getLongExtra(ReminderProvider.COLUMN_ROWID, 0L));
    fragment.setArguments(args);

    FragmentTransaction transaction = getSupportFragmentManager ().beginTransaction();
    transaction.add (R.id.edit_container, fragment, ReminderEditFragment.DEFAULT_EDIT_FRAGMENT_TAG);
    transaction.commit();
    }

}

}

4

1 回答 1

3

是的,你可以试试 putLong 方法,Bundle 没有 putExtra()。putLong(String key, long value) - 将 long 值插入此 Bundle 的映射中,替换给定键的任何现有值。选中此项以查看所有 Bundle 方法: Bundle

于 2013-04-08T20:24:44.430 回答