我在环境中对新的<代码>Adapter至
问题在于,当我开始打字时,我可以从LogCat的Logs那里看到, s状是正确的,是曲线的大小,但我的意见清单充满了新的数据。 它维持不变。 在这里,我怎么做:
这是我首次提出该名单:
cursor = userDbHelper.executeSQLQuery(sqlQuery);
if (cursor.getCount() == 0) {
noCards.setVisibility(View.VISIBLE);
noCards.setText(getString(R.string.no_cards));
} else if (cursor.getCount() > 0) {
noCards.setVisibility(View.GONE);
for (cursor.move(0); cursor.moveToNext(); cursor.isAfterLast()) {
objectId = Integer.parseInt(cursor.getString(cursor.getColumnIndex("objectId")));
cardId.add(objectId);
title = cursor.getString(cursor.getColumnIndex("title"));
catTitle = cursor.getString(cursor.getColumnIndex("catTitle"));
int repeats = Integer.parseInt(cursor.getString(cursor.getColumnIndex("repeatsCount")));
count.add(repeats);
if(extra != 0){
String cardsm = "SELECT objectId FROM cardmedias "
+ "WHERE cardId="
+ objectId
+ " AND mediaType="
+ 5012;
Cursor cardsM = userDbHelper.executeSQLQuery(cardsm);
if (cardsM.getCount() == 0) {
} else if (cardsM.getCount() > 0) {
for (cardsM.move(0); cardsM.moveToNext(); cardsM.isAfterLast()) {
objectID = Integer.parseInt(cardsM.getString(cardsM.getColumnIndex("objectId")));
String filename = "mediacard-"+objectID;
if(storageID==1){
path = RPCCommunicator.getImagePathFromInternalStorage(servername, userId, filename, this);
} else if(storageID==2){
path = RPCCommunicator.getImagePathFromExternalStorage(servername, userId, filename);
}
hm.put(objectID, path);
path = hm.get(objectID);
Log.i("","path : "+path);
paths.add(path);
names.add(title);
categories.add(catTitle);
}
}
} else if (extra==0){
names.add(title);
categories.add(catTitle);
}
}
}
cursor.close();
adapter = new LazyAdapter(this, paths, names, categories, count);
listView.setAdapter(adapter);
而这正是创建新教程和适应器时如何。
searchString = "";
sqlQuery = getSqlQuery(sort, collId, ascDesc,searchString);
searchBar.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
check = 1;
listView.setAdapter(null);
searchString = s.toString();
Log.e("","searchString : "+searchString);
sqlQuery = getSqlQuery(sort, collId, ascDesc,searchString);
Log.e(""," sqlquery : "+sqlQuery);
Cursor cursor = userDbHelper.executeSQLQuery(sqlQuery);
Log.e("","cursor count : "+cursor.getCount());
if (cursor.getCount() == 0) {
noCards.setVisibility(View.VISIBLE);
noCards.setText(getString(R.string.no_cards));
} else if (cursor.getCount() > 0) {
noCards.setVisibility(View.GONE);
for (cursor.move(0); cursor.moveToNext(); cursor.isAfterLast()) {
objectId = Integer.parseInt(cursor.getString(cursor.getColumnIndex("objectId")));
cardId.add(objectId);
title = cursor.getString(cursor.getColumnIndex("title"));
catTitle = cursor.getString(cursor.getColumnIndex("catTitle"));
int repeats = Integer.parseInt(cursor.getString(cursor.getColumnIndex("repeatsCount")));
count.add(repeats);
if(extra != 0){
String cardsm = "SELECT objectId FROM cardmedias "
+ "WHERE cardId="
+ objectId
+ " AND mediaType="
+ 5012;
Cursor cardsM = userDbHelper.executeSQLQuery(cardsm);
if (cardsM.getCount() == 0) {
} else if (cardsM.getCount() > 0) {
for (cardsM.move(0); cardsM.moveToNext(); cardsM.isAfterLast()) {
objectID = Integer.parseInt(cardsM.getString(cardsM.getColumnIndex("objectId")));
String filename = "mediacard-"+objectID;
if(storageID==1){
path = RPCCommunicator.getImagePathFromInternalStorage(servername, userId, filename, OwnedStampii.this);
} else if(storageID==2){
path = RPCCommunicator.getImagePathFromExternalStorage(servername, userId, filename);
}
hm.put(objectID, path);
path = hm.get(objectID);
Log.i("","path : "+path);
paths.add(path);
names.add(title);
categories.add(catTitle);
}
}
} else if (extra==0){
names.add(title);
categories.add(catTitle);
}
}
}
cursor.close();
LazyAdapter adapter = new LazyAdapter(OwnedStampii.this, paths, names, categories, count);
listView.setAdapter(adapter);
}
});
So any ideas how can I refresh my list View with the new adapter. I ve already tried with adapter.notifySetDataChanged();
and it s not working.
提前感谢!