Activity之间的传值方式有很多种,本次项目中主要用到了一下两种简单的传值方式
第一种:通过Intent Extras
//传值
Intent intent = new Intent(this, XXXActivity.class);
intent.putExtra(key, value);
startActivity(intent);
//取值
Intent intent = getIntent();
//获取Intent中的数据
intent.getIntExtra(key, value);//int
intent.getStringExtra(key);//String
第二种:通过Bundle传值
//传值
Intent intent = new Intent(this, XXXActivity.class);
Bundle bundle = new Bundle();
bundle.putInt(key, value);
bundle.putString(value);
intent.putExtras(bundle);
startActivity(intent);
//取值
intent.getExtras();
bundle.getInt(key);
bundle.getString(key);