本文整理匯總了Java中android.widget.SimpleCursorAdapter.notifyDataSetChanged方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleCursorAdapter.notifyDataSetChanged方法的具體用法?Java SimpleCursorAdapter.notifyDataSetChanged怎麽用?Java SimpleCursorAdapter.notifyDataSetChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.SimpleCursorAdapter
的用法示例。
在下文中一共展示了SimpleCursorAdapter.notifyDataSetChanged方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: queryData
import android.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/**
* 關注1
* 模糊查詢數據 & 顯示到ListView列表上
*/
private void queryData(String tempName) {
// 1. 模糊搜索
Cursor cursor = helper.getReadableDatabase().rawQuery(
"select id as _id,name from Search where name like '%" + tempName + "%' order by id desc ", null);
// 2. 創建adapter適配器對象 & 裝入模糊搜索的結果
adapter = new SimpleCursorAdapter(mContext, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
// 3. 設置適配器
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
System.out.println(cursor.getCount());
// 當輸入框為空 & 數據庫中有搜索記錄時,顯示 "刪除搜索記錄"按鈕
if (tempName.equals("") && cursor.getCount() != 0){
tv_clear.setVisibility(VISIBLE);
}
else {
tv_clear.setVisibility(INVISIBLE);
};
}
示例2: queryData
import android.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/**
* 關注1
* 模糊查詢數據 & 顯示到ListView列表上
*/
private void queryData(String tempName) {
// 1. 模糊搜索
Cursor cursor = helper.getReadableDatabase().rawQuery(
"select id as _id,name from records where name like '%" + tempName + "%' order by id desc ", null);
// 2. 創建adapter適配器對象 & 裝入模糊搜索的結果
adapter = new SimpleCursorAdapter(context, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
// 3. 設置適配器
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
System.out.println(cursor.getCount());
// 當輸入框為空 & 數據庫中有搜索記錄時,顯示 "刪除搜索記錄"按鈕
if (tempName.equals("") && cursor.getCount() != 0){
tv_clear.setVisibility(VISIBLE);
}
else {
tv_clear.setVisibility(INVISIBLE);
};
}
示例3: queryData
import android.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
private void queryData(String tempName) {
Cursor cursor = helper.getReadableDatabase().rawQuery(
"select id as _id,name from records where name like '%" +
tempName + "%' order by id desc ", null);
// 創建adapter適配器對象
adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, new String[] { "name" },
new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
// 設置適配器
listview.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
示例4: applySuggestionCursor
import android.widget.SimpleCursorAdapter; //導入方法依賴的package包/類
/**
* Set the suggestion cursor to an Adapter then set it to the search view
*/
private void applySuggestionCursor() {
String[] cols = { COLUMN_NAME_ADDRESS};
int[] to = {R.id.suggestion_item_address};
SimpleCursorAdapter mSuggestionAdapter = new SimpleCursorAdapter(mMapView.getContext(),
R.layout.search_suggestion_item, mSuggestionCursor, cols, to, 0);
mSearchview.setSuggestionsAdapter(mSuggestionAdapter);
mSuggestionAdapter.notifyDataSetChanged();
}