public
void
selectContact(View view){
Intent intent =
new
Intent(
this
,ListContactActivity.
class
);
//startActivity(intent);
//开启新的activity 并且获取他的返回值.
startActivityForResult(intent, 1);
}
public
void
selectContact2(View view){
Intent intent =
new
Intent(
this
,ListContactActivity.
class
);
//startActivity(intent);
//开启新的activity 并且获取他的返回值.
startActivityForResult(intent, 2);
}
@Override
protected
void
onActivityResult(
int
requestCode,
int
resultCode, Intent data) {
if
(data!=
null
){
String phone = data.getStringExtra(
"phone"
);
if
(requestCode==1){
et_number
.setText(phone);
}
else
if
(requestCode==2){
et_number2
.setText(phone);
}
}
super
.onActivityResult(requestCode, resultCode, data);
}
---------------------------------------------------------------------------------------------------------
lv
.setOnItemClickListener(
new
OnItemClickListener() {
@Override
public
void
onItemClick(AdapterView<?> parent, View view,
int
position,
long
id) {
ContactInfo info =
contactInfos
.get(position);
String phone = info.getPhone();
//设置返回的结果 返回给调用者
Intent data =
new
Intent();
data.putExtra(
"phone"
, phone);
setResult(0, data);
finish();
//关闭activity
}
});
}