-2
嗨問題是,選定的數據的出現在列表視圖,但實際上,我們想從列表視圖中刪除數據的檢查意味着位置刪除如何刪除數據從列表視圖後檢查在Android
任何人可以和我們一起解決問題
編碼
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(data!=null){enter code here
Bundle bundle = data.getExtras();
if(requestCode ==1){
selectedConatcts = bundle.getStringArrayList("sel_contacts");
Log.v("", "Selected contacts-->"+selectedConatcts);
if(selectedConatcts.size()<0){
}else{
for(int i =0;i<selectedConatcts.size();i++){
RelativeLayout lnr_inflate = (RelativeLayout)View.inflate(thisActivity, R.layout.contacts_inflate, null);
// EditText edt = (EditText)lnr_inflate.findViewById(R.id.edt_contact);
String selectednames =selectedConatcts.get(i) ;
List<String> stringList = new ArrayList<String>(Arrays.asList(selectednames));
final ListView edt = (ListView)lnr_inflate.findViewById(R.id.edt_contact);
ArrayAdapter<String> adaptercon = new ArrayAdapter<String>(thisActivity, android.R.layout.select_dialog_multichoice,stringList);
edt.setAdapter(adaptercon);
edt.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
edt.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0,
View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
final int len = edt.getCount();
final SparseBooleanArray checked = edt.getCheckedItemPositions();
for(int i =0;i<len;i++){
if (checked.get(i)) {
// selectedContacts.add(names[i]);
// selectedConatcts.get(i);
// selectedConatcts.remove(i);
selectedConatcts.remove(phone_nos[i]);
contactdisp.removeViewAt(i);
//you can you this array list to next activity
// do whatever you want with the checked item
}
// selectedConatcts.get(i);
System.out.println("i m in check button cheked"+selectedConatcts.get(i));
}
selectedConatcts.remove(phone_nos[arg2]);
contactdisp.removeViewAt(arg2);
}
});
contactdisp.addView(lnr_inflate);
}}}}
從數組列表中刪除並重新加載列表視圖 – Signare
請張貼 – PPartisan
謝謝嗨這裏signare你的ListView的代碼,我需要個人數據刪除需要進行不執行整個列表 –