Can anyone tell me how to show the soft input keyboard while a activity opens. In Normal case a keyboard pops up when we tap inside the edit text but i want to open it automatically when that screen loads.
here is the xml layout file
and here is the main.xml layout file
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:te开发者_如何学Cxt="This is my sample App of android"
android:textColor="#000000" android:textSize="20dip">
</TextView>
<EditText android:id="@+id/EditText01" android:layout_height="wrap_content"
android:layout_width="fill_parent"></EditText>
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Say Hello"></Button>
Check android:windowSoftInputMode
attribute for activity
element of AndroidManifest.xml. In your case it could be:
<activity android:windowSoftInputMode="stateAlwaysVisible" ... />
<activity android:windowSoftInputMode="stateAlwaysVisible" ... />
as Ralkie's answer. But to test on emulator you have to be careful in how your AVD is configured: the default configuration has keyboard support... You need to add the hardware property "Keyboard support" with "no" value on your AVD in order to test it on emulator.
精彩评论