public class ContactActivity extends Activity implements OnClickListener { //实现点击侦听
private int id;
private String name1;
private String name2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact);
TextView tv_name1 = (TextView) findViewById(R.id.tv1);
TextView tv_name2 = (TextView) findViewById(R.id.tv2);
name1 = tv_name1.getText().toString();
name2 = tv_name2.getText().toString();
tv_name1.setOnClickListener(this);
tv_name2.setOnClickListener(this);
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.tv1:
Intent data = new Intent();
data.putExtra("name1", name1);
setResult(0, data);
finish();
break;
case R.id.tv2:
Intent data1 = new Intent();
data1.putExtra("name2", name2);
setResult(1, data1);
finish();
break;
default:
break;
}
}
}
Android 点击
最新推荐文章于 2022-01-11 13:22:10 发布