js定义类
public class StartIntentForResultDemo extends Activity {
private EditText ev;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
ev = (EditText) findViewById(R.id.editview);
Button bn = (Button) findViewById(R.id.mybtn2);
bn.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(StartIntentForResultDemo.this, ValueForMain.class);
startActivityForResult(intent, 0);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (resultCode)
{
case RESULT_OK:
Bundle b = data.getExtras();
String txt = b.getString("txt");
ev.setText(txt);
break;
default:
break;
}
}