我是新学员
当我从我买的书中复制练习代码时,它告诉我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();
}
}
}
答案 0 :(得分:3)
是的,你可以尝试putLong方法,Bundle没有putExtra()。 putLong(字符串键,长值) - 在此Bundle的映射中插入一个long值,替换给定键的任何现有值。 选中此项以查看所有Bundle方法: Bundle