android关于输入框弹出后 点击输入框以外的位置会让输入框消失

    xiaoxiao2026-03-20  12

    http://blog.csdn.net/cwc455826074/article/details/6883467

    XML里的

     

    [html] view plain copy <?xml version="1.0" encoding="utf-8"?>  <resources  xmlns:android="http://schemas.android.com/apk/res/android">      <style name="demo" parent="android:Theme">          <item name="android:focusableInTouchMode">true</item>      </style>  </resources>  

    //AnroidMainifest里的

    [html] view plain copy android:theme="@style/demo"  

    //Java代码里的

    [html] view plain copy //点击输入框以外的地方则隐藏输入法  addfoodweight.setOnFocusChangeListener(new OnFocusChangeListener() {      @Override      public void onFocusChange(View v, boolean hasFocus) {          // TODO Auto-generated method stub          if (!hasFocus) {              System.out.println("失去焦点");              // 失去焦点              addfoodweight.clearFocus();              InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);              imm.hideSoftInputFromWindow(addfoodweight.getWindowToken(), 0);          }      }  }); 
    转载请注明原文地址: https://ju.6miu.com/read-1308155.html
    最新回复(0)