我们先来看看为什么会出现上述情况,原因很简单,文本框默认是会获得焦点的,获得焦点之后当然会继续弹出输入框,等待输入,针对此原因,我们可以有以下两种方案:
1、不让文本框获得焦点;
2、获得焦点不弹出输入框;
来看第一种方法,我们可以抢占文本框的焦点,如在其父窗体中加入:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context=".MainActivity" >
<EditText
android:id="@+id/etMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
来看第二种方法,在activity中加入:
android:windowSoftInputMode = "stateHidden"
我的 博客其它文章列表
http://my.oschina.net/helu