1

我在底部有自定义列表视图的自动完成视图。当我搜索任何单词并单击它时,我可以成功将该单词添加到我的列表视图中,但同时我想从自动完成视图中删除该文本或该索引,但它不起作用请帮助

String[] from = {"field","subject","topic"};

  int[] to = {R.id.field,R.id.subject,R.id.topic};

  adapter = new SimpleAdapter(getBaseContext(), aList, R.layout.autocomplete_layout, from, to);        

  CustomAutoCompleteTextView autoComplete = (CustomAutoCompleteTextView) findViewById(R.id.autocomplete);

  OnItemClickListener itemClickListener = new OnItemClickListener()
  {
    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {

        HashMap<String, String> hm = (HashMap<String, String>) arg0.getAdapter().getItem(position);

        code=hm.get("topicCode");
        topicCode.add(code);
        mySQLiteAdapter.openToRead();
        c = mySQLiteAdapter.selectRaw(code);

        if(c.getCount() > 0)
        {
            startManagingCursor(c);
            String un = c.getString(4);


            boolean exist=false;


            for(int i=0;i<topicsList.size();i++)
            {
                if(topicsList.get(i).getCode().equals(un)){
                    exist=true;
                    break;
                }
            }

           if(exist==false)
           {
             Topics topics = new Topics(un);
             topicsList.add(topics);
             dataAdapter.notifyDataSetChanged();
            }
        }

            //I tried this two line but its not working for me
        aList.remove(hm);
        adapter.notifyDataSetChanged();

    }
    };
  autoComplete.setOnItemClickListener(itemClickListener);
  autoComplete.setAdapter(adapter); 
4

0 回答 0