将您的代码更改为将数据从第一个活动发送到第二个活动:
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
/*Create new Intent Object, and specify class*/
Intent intent = new Intent();
intent.setClass(EMPID.this,INFO.class);
/*new Bundle Object, and put data in bundle object*/
Bundle bundle = new Bundle();
bundle.putString("EMPID ","empid");
/*Put Bundle object i.e bundle in intent*/
intent.putExtras(bundle);
EMPID.this.startActivity(intent);
@Override
public void onResume()
{
//SET EDITVIEW VALUE HERE to EMPID
super.onResume();
}
在活动信息中:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.receivermain);
TextView txtvwreceived=(TextView)findViewById(R.id.txtviewsender);
/* Intent To obtain the bundle object from EMPID */
Bundle bundle = this.getIntent().getExtras();
/* Obtain String from Intent */
if(bundle !=null)
{
/* Obtain Data from bundle object */
String strdata = bundle.getString("EMPID");
}
}
第二种方法使用第一个活动(EMPID.class)中的startActivityForResult()
覆盖onActivityResult
方法来启动您的第二个活动(INFO.class)以设置 EditView 值。