更新时间:2023-12-03 16:18:16
您需要使用 Intent 才能将数据发送到另一个活动
you need use Intent in order to send data to another activity
@Override
public void onClick(View v) {
Book book = new Book(mBkTitle.getText().toString(),
mBkAuthor.getText().toString());
Intent intent = new Intent(MainActivity.this, BookActivity.class);
intent.putExtra("Book", book);
startActivity(intent);
}
数据需要从Parcelable扩展
data need to extends from Parcelable
public class Book implements Parcelable {
// book basics
private String title;
private String author;
}
使用 http://www.jsonschema2pojo.org/帮助您使类可拆分.
use http://www.jsonschema2pojo.org/ to help you make class parcelable.
查看本教程