我实现了一个PopupWindow+listview自定义的下拉列表,但是当点击item之后,l列表收不回去是怎么回事, public void afterTextChanged(Editable e) { 
        String term = e.toString(); 
        Log.d("term", term); 
        if (e != null && !term.equals("")) { 
         mohu_findrules = lawDao.mohu_findrules(term); 
         if (mohu_findrules.size() > 0) { 
          termlist = new ListView( 
            LawMainActivity.this);//创建listview 
          fuzzyQueryAdapter = new FuzzyQueryAdapter( 
            LawMainActivity.this, 
            mohu_findrules);//这是加载数据的adapter 
          PopUtil.createpop(termlist, 
            fuzzyQueryAdapter, lm_et, -10);//调用创建popwindow 
          termlist.setOnItemClickListener(new OnItemClickListener() { 
           @Override 
           public void onItemClick( 
             AdapterView<?> parent, 
             View view, int position, long id) { 
            String termname = (String) parent 
              .getItemAtPosition(position); 
            lm_et.setText(termname); 
            PopUtil.closepop();//相应item的时候popwindow消失。但是消失不了, 
           } 
          }); 
         } 
        } 
       } 下面是PopUtil类, public static void createpop(ListView lv,ListAdapter adapter,View v,int n){ 
   lv.setCacheColorHint(0x00000000);// 缓冲色 设置透明色 
   lv.setVerticalScrollBarEnabled(false); 
   lv.setDivider(null);// 取消item分割线 
   lv.setAdapter(adapter); 
   
   pop=new PopupWindow(lv, v.getWidth(), LayoutParams.WRAP_CONTENT, true); 
   pop.setBackgroundDrawable(new ColorDrawable(0x33000000)); 
   pop.showAsDropDown(v, 0, n); 
   

public static void closepop(){ 
   pop.dismiss(); 
} 我整个项目都是用的这一个类,所有的都可以弹回去,唯独这一个收不回去,谁知道怎么回事,指点一下,谢谢各位。 

解决方案 »

  1.   

    public static void createpop(ListView lv,ListAdapter adapter,View v,int n){ 
        lv.setCacheColorHint(0x00000000);// 缓冲色 设置透明色 
        lv.setVerticalScrollBarEnabled(false); 
        lv.setDivider(null);// 取消item分割线 
        lv.setAdapter(adapter); 
        
        pop=new PopupWindow(lv, v.getWidth(), LayoutParams.WRAP_CONTENT, true); 
        pop.setBackgroundDrawable(new ColorDrawable(0x33000000)); 
        pop.showAsDropDown(v, 0, n); 
        //这里需要update下pop.update();
     } 
      

  2.   

    可以在 
    lm_et.setText(termname); 
    lm_et.clearFocus();//加上这个试试
    PopUtil.closepop();