本文整理汇总了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();
}