CustomAutoCompleteTextView删除内容onclick

时间:2013-02-27 03:51:16

标签: android

我的自动填充视图底部带有自定义列表视图。当我搜索任何单词并单击它时,我可以成功地将该单词添加到我的列表视图中,但同时我想从auto completview中删除该文本或该索引,但它不起作用plz help

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); 

0 个答案:

没有答案