Passwhl 2017-03-25 03:19 采纳率: 100%
浏览 1410
已采纳

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焦点还在,点击也不再弹出软键盘

  • 写回答

5条回答

  • Mr康 2017-03-25 05:18
    关注

    那你就手写软键盘出现与隐藏的代码,然后判断
    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" 屏幕整体上移

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突