我无法编辑listView需要onContextItemSelected

时间:2014-03-06 11:07:16

标签: android listview

@Override
    public boolean onContextItemSelected(MenuItem item) {
        // AdapterContextMenuInfo info=
        // (AdapterContextMenuInfo)item.getMenuInfo();
        // TODO Auto-generated method stub
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
                .getMenuInfo();

        switch (item.getItemId()) {
        case R.id.menu_delete:

            this.results.remove(info.position);
            ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, results);
            setListAdapter(mAdapter);
            mAdapter.notifyDataSetChanged();
            return true;

        case R.id.menu_editar:

            this.results.add(info.position, null);
            ArrayAdapter<String> mAdapter1 = new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, results);
            setListAdapter(mAdapter1);
            mAdapter1.notifyDataSetChanged();
            return true;
        default:

            return super.onContextItemSelected(item);
        }
    }

我正在尝试编辑一个旅行并存储在listView中,我设法删除但不编辑。

我将不胜感激任何帮助或示例。

感谢您的帮助

0 个答案:

没有答案