1
在我的應用程序中,我有很多edittext視圖從電話簿獲取聯繫人,當我選擇第一個edittext視圖的聯繫人時,我不希望同一聯繫人在第二個一個。怎麼做。Android刪除已經選擇的聯繫人,同時發送短信
String selectedNum = " ";
public void showSelectedNumber(String name, String number, int type) {
if (layoutLinear == null) {
Log.i("layoutLinear is null", "null");
} else {
Log.i("layoutLinear is not null", "not null");
}
EditText userNumber = (EditText) layoutLinear.getChildAt(0);
if (userNumber == null) {
Log.i("edittext is null", "null");
} else {
Log.i("edittext is not null", "not null");
}
String typeNumber = (String) ContactsContract.CommonDataKinds.Phone
.getTypeLabel(getResources(), type, "");
//preventing number duplicacy and raising toast
if(selectedNum.contains(number)){
// do nothing
// alert user that number is already selected
Toast.makeText(getApplicationContext(), "Selected Contact Already Exists", Toast.LENGTH_SHORT).show();
}else
userNumber.setText(name+":"+number+" "+typeNumber);
selectedNum= selectedNum+number;
}
}// final parentheses
你爲什麼要刪除代碼?不要這樣做,它也可以幫助其他用戶。 –
好吧,讓我再說一遍,實際上我是jst粘貼showSelectedNumber代碼片段。我應該保留整個代碼,還是隻有這個? –