0
我有Activiti,其中有一個ListView的搜索。當我返回任何結果時,我不使用過濾器,一切都很好。選擇元素520,我得到它的ID,但只要我使用過濾器,並找到相同的項目,獲得ID 0-10。請告訴我如何解決這個問題。提前致謝! P.S. 我很抱歉我的英語!在ListView中搜索,獲取id的錯誤結果onItemClick
public class Clients extends Activity {
private ListView lv;
ArrayAdapter<String> adapter;
EditText etInputSearch;
DB dbSync;
DB dbUser;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.clients);
dbSync = new DB(this);
dbUser = new DB(this);
lv = (ListView) findViewById(R.id.list_view);
etInputSearch = (EditText) findViewById(R.id.etInputSearch);
adapter = new ArrayAdapter<String>(this, R.layout.clients_item, R.id.clients_name, dbSync.createlistClients(dbUser.getCodeAgent()));
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> l, View v, int position,
long id) {
Log.d("TAG", position + " " + id);
}
});
etInputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
Clients.this.adapter.getFilter().filter(cs);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {}
@Override
public void afterTextChanged(Editable arg0) {}
});
}
}