android数据Activity传值的问题

初学,这段代码也是在网上找的

Intent intentSimple = new Intent();
intentSimple.setClass(Layout_1.this,Layout_2.class);

Bundle bundleSimple = new Bundle();
bundleSimple.putString("username", username);
bundleSimple.putString("password",password);
intentSimple.putExtras(bundleSimple);
startActivity(intentSimple);

请问为什么出现错误?

阅读 3.1k
1 个回答

你贴的代码没问题,检查一下接受值时有没有问题,问题应该是在Layout_2.class里

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题