PopupWindow中EditText被touc时弹出键盘异常解决办法

按钮点击事件..弹出popupwindow. .

edittext已获取焦点,但未弹出软键盘 点击时.手动控制弹出软键盘.

@Override
 public void onClick(View v) {
  switch (v.getId()) {
  case R.id.rightButton:
   if(!"↓搜索".equals(getRigButton().getText())){
    return;
   }
   if(mpop == null){
    mpop = MyTools.getPopupWindow(this, R.layout.search_pop, R.style.PopupAnimation,LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
    mpop.getContentView().findViewById(R.id.search).setOnClickListener(this);
    mpop.getContentView().findViewById(R.id.searchEdit).setOnTouchListener(new View.OnTouchListener() {
     @Override
     public boolean onTouch(View v, MotionEvent event) {
      if(event.getAction() == MotionEvent.ACTION_UP){
      InputMethodManager imm =(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.showSoftInput(mpop.getContentView().findViewById(R.id.searchEdit), 0);
       return true;
      }
      return true;
     }
    });
    mpop.getContentView().findViewById(R.id.searchEdit).setOnFocusChangeListener(new OnFocusChangeListener() {
     @Override
     public void onFocusChange(View v, boolean hasFocus) {
      if(hasFocus){
       mpop.getContentView().findViewById(R.id.search).setVisibility(View.VISIBLE);
      }else{
       mpop.getContentView().findViewById(R.id.search).setVisibility(View.GONE);
      }
     }
    });
    mpop.setOnDismissListener(new OnDismissListener() {
     @Override
     public void onDismiss() {
      getRigButton().setText("↓搜索");
     }
    });
    mpop.showAsDropDown(getRigButton());
   }else{
    mpop.showAsDropDown(getRigButton());
   } 
   mpop.getContentView().findViewById(R.id.search).setVisibility(View.VISIBLE);
   getRigButton().setText("↑搜索");
   break;
 }

你可能感兴趣的:(service,null,UP)