I have a database as follows:
------------------------------
BOOK NAME | BOOK FORMAT | COUNT |
------------------------------
Android | HTML | 1
WPF | PDF | 10
Symbian | PS | 2
Windows | HTML | 2
I am showing this database to the user
by making use of a CustomSimpleCursorAdapter.
CustomSimpleCursorAdapter extends SimpleCursorAdapter
implements Filterable
with getView()
& runQueryonBackgroundThread()
being overriden.
The Grid view of books is properly shown.
The user has the following options:
HTML | PDF | PS | DELETE
Constraint: BOOK FORMAT
[HTML - 1, PDF - 2, PS - 3]
When the user presses HTML menu option, the books with HTML
type has to be shown.
inside MenuOption handler(), I wrote as follows:
adapter.getFilter().filter("1");
runQueryonBackgroundThread() {
if(mCursor != null)
mCursor.close();
mCursor = query(using the constraint)
return mCursor;
}
This constraint reaching my overriden runQueryonBackgroundThread()
method. But its not updating the grid view and throws an exception.
"FILTER: android.view.ViewRoot$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views"
Please help me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…