在这里,我有一个Activity在其中创建ImageButton的XML,像这样ImageButton安排二ImageViews和二TextViews,请参阅单击此ImageButton数据在下一步中接收Activity。
我的问题是如何ImageButton从这个Activity到下一个获取所有数据Activity。任何人有想法给一些想法....
在这里,我有一个Activity在其中创建ImageButton的XML,像这样ImageButton安排二ImageViews和二TextViews,请参阅单击此ImageButton数据在下一步中接收Activity。
我的问题是如何ImageButton从这个Activity到下一个获取所有数据Activity。任何人有想法给一些想法....
您可以将所需的数据保存在 a 中Bundle并将其传递到Intent. Button如果您绝对需要Serializable传递Button. 并使用此答案中Serializable的方法Activity通过Intent.
单击按钮时,只需将要移动的数据放入其他活动中
public void onClick(View view) {
Intent i = new Intent(this, ActivityTwo.class);
i.putExtra("Value1", "This value one for ActivityTwo ");
i.putExtra("Value2", "This value two ActivityTwo");
// Set the request code to any code you like, you can identify the
// callback via this code
startActivityForResult(i, REQUEST_CODE);
}
然后您可以像这样将这些数据放入其他活动中
Bundle extras = getIntent().getExtras();
if (extras == null) {
return;
}
String value1 = extras.getString("Value1");
String value2 = extras.getString("Value2");
这称为显式意图。