1 |
package soo.elements.intent; |
---|
2 |
|
---|
3 |
import android.app.Activity; |
---|
4 |
import android.content.Intent; |
---|
5 |
import android.os.Bundle; |
---|
6 |
import android.view.View; |
---|
7 |
import android.view.View.OnClickListener; |
---|
8 |
import android.widget.Button; |
---|
9 |
import android.widget.TextView; |
---|
10 |
|
---|
11 |
public class ExIntenttDataTest extends Activity { |
---|
12 |
/** Called when the activity is first created. */ |
---|
13 |
|
---|
14 |
TextView tv1,tv2; |
---|
15 |
@Override |
---|
16 |
public void onCreate(Bundle savedInstanceState) { |
---|
17 |
super.onCreate(savedInstanceState); |
---|
18 |
setContentView(R.layout.main); |
---|
19 |
|
---|
20 |
final Button bt = (Button)findViewById(R.id.button01); |
---|
21 |
|
---|
22 |
bt.setOnClickListener(new OnClickListener() { |
---|
23 |
|
---|
24 |
@Override |
---|
25 |
public void onClick(View v) { |
---|
26 |
tv1 = (TextView)findViewById(R.id.textView01); |
---|
27 |
tv2 = (TextView)findViewById(R.id.textView02); |
---|
28 |
// TODO Auto-generated method stub |
---|
29 |
Intent i = new Intent(ExIntenttDataTest.this,SubForm.class); |
---|
30 |
i.putExtra("param_name", tv1.getText()); |
---|
31 |
i.putExtra("param_addr", tv2.getText()); |
---|
32 |
startActivityForResult(i,1 ); //���瑜�二쇰� 寃���� 1����껌肄��(requestCode) �대�.. |
---|
33 |
} |
---|
34 |
}); |
---|
35 |
} |
---|
36 |
|
---|
37 |
@Override |
---|
38 |
protected void onActivityResult(int requestCode,int resultCode,Intent data){ |
---|
39 |
tv1 = (TextView)findViewById(R.id.textView01); |
---|
40 |
tv2 = (TextView)findViewById(R.id.textView02); |
---|
41 |
|
---|
42 |
if(resultCode == RESULT_OK){ //���濡�諛���������. |
---|
43 |
if(requestCode==1){ |
---|
44 |
String name = data.getStringExtra("param_name"); |
---|
45 |
String addr = data.getStringExtra("param_addr"); |
---|
46 |
|
---|
47 |
tv1.setText(name); |
---|
48 |
tv2.setText(addr); |
---|
49 |
} |
---|
50 |
} |
---|
51 |
} |
---|
52 |
} |
---|