我在这里面临一个问题,我的listview是过滤器分区,就像手机联系人一样,现在用于onitemclick im使用
AdapterView.OnItemClickListener
并使用此方法:
@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
// mCursor.moveToPosition(position);
// String rowId = mCursor.getString(0); //Column 0 of the cursor is the id
// mDb.delete(MyDbHelperContacts.TABLE_NAME, "_id = ?", new String[]
{rowId});
// mCursor.requery();
AsyncDelete async = new AsyncDelete();
String newstring=String.valueOf(position);
async.execute(newstring);
System.out.println("im here");
// mAdapter.notifyDataSetChanged();
}
////////////Delete
public class AsyncDelete extends AsyncTask<String, String ,String>{
@Override
protected String doInBackground(String... params) {
int newparams=Integer.parseInt(params[0]);
mCursor.moveToPosition(newparams);
String rowId = mCursor.getString(1); //Column 1 of the cursor is the username
System.out.println(rowId);
mDb.delete(MyDbHelperContacts.TABLE_NAME, "_id = ?", new String[]{rowId});
names.remove(rowId);
mCursor.requery();
return null;
}
@Override
protected void onPostExecute(String result) {
mAdaptor.notifyDataSetChanged();
// mAdapter.notifyDataSetChanged();
super.onPostExecute(result);
}
}
但是当我点击一个项目时,它说例如索引3请求大小为3,我理解列表stasrts从4,所以请求的索引实际上是4不存在,但是当我放一个&# 34; -1&#34;它移动到错误位置的位置,而我没有看到任何错误,即使它将部分计为一排。能帮帮我吗