adapter.notifyDataSetChanged()软键盘隐藏了

<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:id="@+id/head"
    android:layout_width="match_parent"
    android:layout_height="@dimen/head_bar_height"
    android:background="@color/main">

    <ImageView
        android:id="@+id/back"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:padding="12dp"
        android:src="@mipmap/ic_back" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="信息审计"
        android:textColor="@color/white_text"
        android:textSize="@dimen/head_bar_text_size" />
</RelativeLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@color/white_bg">

    <EditText
        android:id="@+id/etSearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="输入关键字"
        android:singleLine="true"
        android:maxLength="25"/>

    <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="@color/black_text"
        android:layout_marginTop="6dp"
        android:layout_marginBottom="6dp"/>

    <Spinner
        android:layout_width="120dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/audit_select"
        android:layout_marginRight="6dp"
        android:background="@drawable/down"></Spinner>
</LinearLayout>

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/audit_srl"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/audit_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</android.support.v4.widget.SwipeRefreshLayout>

在Activity中的一个Fragment
界面很简单就是一个editText和Spinner
下边一个listView
//搜索框
etSearch = (EditText) view.findViewById(R.id.etSearch);
etSearch.addTextChangedListener(new SimTextWatcher() {
@Override
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
keyWord = charSequence.toString();
search(); //同步按照keyword查找
adapter.notifyDataSetChanged();
}
});
任意输入一个字母,不存在结果的软键盘就自动隐藏了
EditText焦点还在,点击也不再弹出软键盘

那你就手写软键盘出现与隐藏的代码,然后判断
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

// 获取软键盘的显示状态
boolean isOpen=imm.isActive();

// 如果软键盘已经显示,则隐藏,反之则显示
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

// 隐藏软键盘
imm.hideSoftInputFromWindow(view, InputMethodManager.HIDE_NOT_ALWAYS);

// 强制显示软键盘
imm.showSoftInput(view,InputMethodManager.SHOW_FORCED);

// 强制隐藏软键盘
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
在你清单文件中 android:windowSoftInputMode="adjustPan" 键盘就会覆盖屏幕
android:windowSoftInputMode="stateVisible|adjustResize" 屏幕整体上移

//搜索
public void search() {
userList.clear();
if (serviceType.equals("全部") && keyWord.equals("")) {
userList.addAll(BaseActivity.onlineUsers);
adapter.notifyDataSetChanged();
return;
}
for (OnlineUser user : BaseActivity.onlineUsers) {
boolean istarget = false;
if (user.mac.indexOf(keyWord) != -1) { //mac模糊匹配
istarget = true;
} else {
for (VIdentity vi : user.realnameId) {
if (serviceType.equals("全部")) {
if (vi.vi_identity.indexOf(keyWord) != -1) {
istarget = true;
}
} else {
if (serviceType.equals(vi.service_type.serviceName) && vi.vi_identity.indexOf(keyWord) != -1) {
istarget = true;
}
}
}
}
if (istarget) {
userList.add(user);
}
}
}

//列表适配器
public class UserAdapter extends BaseAdapter {

    @Override
    public int getCount() {
        return userList.size();
    }

    @Override
    public OnlineUser getItem(int i) {
        return userList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHold viewHold = null;
        if (view == null) {
            view = LayoutInflater.from(baseActivity).inflate(R.layout.audit_list_item, null);
            viewHold = new ViewHold();
            viewHold.tvMac = (TextView) view.findViewById(R.id.audit_mac_tv);
            viewHold.tvVid = (TextView) view.findViewById(R.id.audit_id_tv);
            view.setTag(viewHold);
        }
        viewHold = (ViewHold) view.getTag();
        OnlineUser user = getItem(i);
        viewHold.tvMac.setText(user.mac.toUpperCase());
        if (user.realnameId != null && user.realnameId.size() > 0) {
            StringBuilder sb=new StringBuilder();
            for (VIdentity v : user.realnameId) {
                sb.append(v.service_type.serviceName + ":" + v.user_online_id);
            }
            viewHold.tvVid.setText(sb.toString());
        } else {
            viewHold.tvVid.setText("暂无虚拟身份");
        }

        return view;
    }

    class ViewHold {
        public TextView tvMac;
        public TextView tvVid;
    }
}

会不会内存太卡,多试几下。。。

可能是下面的把他给覆盖了