这是我的onClick信息:BookListing项目。每本图书搜索都会覆盖以前的结果。你如何清除ListView?
Button searchButton = (Button) findViewById(R.id.search_button);
searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BookListFragment bookListFragment = new BookListFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.book_list_frame, bookListFragment).commit();
}
});
BookListFragment W/BookLoader:
@Override
public Loader<List<BookListing>> onCreateLoader(int i, Bundle args) {
return new BookLoader(this, GOOGLE_BOOKS_URL + searchedBook);
}
@Override
public void onLoadFinished(Loader<List<BookListing>> loader, List<BookListing> bookListings) {
mAdapter.clear();
if(bookListings != null && !bookListings.isEmpty()) {
mAdapter.addAll(bookListings);
}
}
@Override
public void onLoaderReset(Loader<List<BookListing>> loader) {
mAdapter.clear();
}
我能够得到的搜索结果。但是当再次搜索时,以前的结果不明确。他们只是不断重叠。
First Search Screenshot Second Search Screenshot
重复答案? – phpdroid
@phpdroid我在写回复时他张贴 –