Android 为什么我在开始新的意图时会看到键盘?
我的android应用程序有一个问题:当我开始这样一个新的应用程序时:Android 为什么我在开始新的意图时会看到键盘?,android,Android,我的android应用程序有一个问题:当我开始这样一个新的应用程序时: Intent i = new Intent(MyFirstActivity.this, MySecondActivity.class); startActivity(i); 当我看到MySecondActivity时,android会打开键盘,我不知道为什么 如何禁用此功能 编辑:这是我的布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/re
Intent i = new Intent(MyFirstActivity.this, MySecondActivity.class);
startActivity(i);
当我看到MySecondActivity
时,android会打开键盘,我不知道为什么
如何禁用此功能
编辑:这是我的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MySecondActivity" >
<Button
android:id="@+id/foo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/edit" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/editTextBemerkung"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:hint="@string/bemerkung" />
<AutoCompleteTextView
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:hint="@string/foo" />
<Button
android:id="@+id/foo2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/foo"
android:visibility="gone" />
<ImageView
android:id="@+id/imageViewFoto2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:contentDescription="@string/foto"
android:src="@drawable/ic_launcher"
android:visibility="gone" />
<TextView
android:id="@+id/textViewAnzahl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/anzahl" />
<TextView
android:id="@+id/foo3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/foo" />
<TextView
android:id="@+id/foo4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/foo" />
<AutoCompleteTextView
android:id="@+id/foo6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:hint="@string/foo" />
<AutoCompleteTextView
android:id="@+id/foo7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:hint="@string/foo" />
<TextView
android:id="@+id/foo8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/foo" />
<CheckBox
android:id="@+id/foo9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/foo" />
</LinearLayout>
</ScrollView>
</LinearLayout>
如果您有任何正在聚焦的编辑文本/可聚焦输入,则键盘将打开。在该视图的布局xml中使用以下内容:
android:focusable="false"
android:focusableInTouchMode="false"
所以它会像:
<EditText
android:id="@+id/editTextBemerkung"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:enabled="false"
android:hint="@string/bemerkung"
android:focusable="false"
android:focusableInTouchMode="false" />
希望这有帮助 如上所述,这很可能是因为当
活动开始时,您的编辑文本
具有焦点,因此您可以将焦点赋予不同的视图
,或者您可以添加
android:windowSoftInputMode="stateHidden
在处理键盘时,您的还有一些其他有用的属性向我们展示布局。您是否有获得关注的输入?如果它对您有效,您可以接受它作为答案,并且对查看此帖子的其他人也有帮助。:)