Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ListView删除项目_Android_Listview - Fatal编程技术网

Android ListView删除项目

Android ListView删除项目,android,listview,Android,Listview,如何删除ListView中的项?我没有找到删除函数 ShopList = (ListView) findViewById( R.id.shopList ); ShopList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); Cursor c = getContentResolver().query(SHOP_LIST_URI, null, null, null, null); String[] from = { DB.column_name

如何删除ListView中的项?我没有找到删除函数

ShopList = (ListView) findViewById( R.id.shopList );
ShopList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
Cursor c = getContentResolver().query(SHOP_LIST_URI, null, null, null, null);
String[] from = { DB.column_name };
int[] to = { android.R.id.text1 };
shopAdapter = new SimpleCursorAdapter(
        this, android.R.layout.simple_list_item_activated_1, c, from, to, 
        SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
ShopList.setAdapter(shopAdapter);
如何删除ListView中的项?我没有找到删除函数

ShopList = (ListView) findViewById( R.id.shopList );
ShopList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
Cursor c = getContentResolver().query(SHOP_LIST_URI, null, null, null, null);
String[] from = { DB.column_name };
int[] to = { android.R.id.text1 };
shopAdapter = new SimpleCursorAdapter(
        this, android.R.layout.simple_list_item_activated_1, c, from, to, 
        SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
ShopList.setAdapter(shopAdapter);
您不能从
列表视图中删除项目。您可以修改或替换
列表适配器
,使其不再具有该项。在您的情况下,由于您使用的是
SimpleCursorAdapter
,因此需要:

  • 从数据库中删除该项(在您的情况下,通过
    ContentProvider

  • 获取一个表示查询结果的新的
    光标

  • 调用
    changeCursor()
    (如果您使用的是
    Loader
    框架)或
    swapCursor()
    ,将
    SimpleCursorAdapter
    中的
    光标替换为新光标

由于您不应该在主应用程序线程上调用
ContentResolver
上的
query()
,因此您可能希望切换到
CursorLoader
,在这种情况下,您可以在
onLoadFinished()
中调用
changeCursor()

如何删除ListView中的项?我没有找到删除函数

ShopList = (ListView) findViewById( R.id.shopList );
ShopList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
Cursor c = getContentResolver().query(SHOP_LIST_URI, null, null, null, null);
String[] from = { DB.column_name };
int[] to = { android.R.id.text1 };
shopAdapter = new SimpleCursorAdapter(
        this, android.R.layout.simple_list_item_activated_1, c, from, to, 
        SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
ShopList.setAdapter(shopAdapter);
您不能从
列表视图中删除项目。您可以修改或替换
列表适配器
,使其不再具有该项。在您的情况下,由于您使用的是
SimpleCursorAdapter
,因此需要:

  • 从数据库中删除该项(在您的情况下,通过
    ContentProvider

  • 获取一个表示查询结果的新的
    光标

  • 调用
    changeCursor()
    (如果您使用的是
    Loader
    框架)或
    swapCursor()
    ,将
    SimpleCursorAdapter
    中的
    光标替换为新光标

由于您不应该在主应用程序线程上调用
ContentResolver
上的
query()
,因此您可能希望切换到
CursorLoader
,在这种情况下,您可以在
onLoadFinished()
中调用
changeCursor()

如何删除ListView中的项?我没有找到删除函数

ShopList = (ListView) findViewById( R.id.shopList );
ShopList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
Cursor c = getContentResolver().query(SHOP_LIST_URI, null, null, null, null);
String[] from = { DB.column_name };
int[] to = { android.R.id.text1 };
shopAdapter = new SimpleCursorAdapter(
        this, android.R.layout.simple_list_item_activated_1, c, from, to, 
        SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
ShopList.setAdapter(shopAdapter);
您不能从
列表视图中删除项目。您可以修改或替换
列表适配器
,使其不再具有该项。在您的情况下,由于您使用的是
SimpleCursorAdapter
,因此需要:

  • 从数据库中删除该项(在您的情况下,通过
    ContentProvider

  • 获取一个表示查询结果的新的
    光标

  • 调用
    changeCursor()
    (如果您使用的是
    Loader
    框架)或
    swapCursor()
    ,将
    SimpleCursorAdapter
    中的
    光标替换为新光标

由于您不应该在主应用程序线程上调用
ContentResolver
上的
query()
,因此您可能希望切换到
CursorLoader
,在这种情况下,您可以在
onLoadFinished()
中调用
changeCursor()

如何删除ListView中的项?我没有找到删除函数

ShopList = (ListView) findViewById( R.id.shopList );
ShopList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
Cursor c = getContentResolver().query(SHOP_LIST_URI, null, null, null, null);
String[] from = { DB.column_name };
int[] to = { android.R.id.text1 };
shopAdapter = new SimpleCursorAdapter(
        this, android.R.layout.simple_list_item_activated_1, c, from, to, 
        SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
ShopList.setAdapter(shopAdapter);
您不能从
列表视图中删除项目。您可以修改或替换
列表适配器
,使其不再具有该项。在您的情况下,由于您使用的是
SimpleCursorAdapter
,因此需要:

  • 从数据库中删除该项(在您的情况下,通过
    ContentProvider

  • 获取一个表示查询结果的新的
    光标

  • 调用
    changeCursor()
    (如果您使用的是
    Loader
    框架)或
    swapCursor()
    ,将
    SimpleCursorAdapter
    中的
    光标替换为新光标


由于您不应该在主应用程序线程上调用
ContentResolver
上的
query()
,因此您可能希望切换到
CursorLoader
,在这种情况下,您可以在
onLoadFinished()
中调用
changecoursor()
,首先从数据库中删除数据,然后添加数据

swapCursor(getContentResolver().query(SHOP_LIST_URI,null,null,null))


首先从数据库中删除数据,然后添加

swapCursor(getContentResolver().query(SHOP_LIST_URI,null,null,null))


首先从数据库中删除数据,然后添加

swapCursor(getContentResolver().query(SHOP_LIST_URI,null,null,null))


首先从数据库中删除数据,然后添加

swapCursor(getContentResolver().query(SHOP_LIST_URI,null,null,null))


AFIK,仅当从数据源中删除项目时,才能从列表视图中删除项目。AFIK,仅当从数据源中删除项目时,才能从列表视图中删除项目。AFIK,仅当从数据源中删除项目时,才能从列表视图中删除项目。AFIK,仅当从数据源中删除某项时,才能从listview中删除该项。