Turn off soft input panel

Description

Get EditText to automatically have the focus, but you do not want the soft input panel (keyboard) to appear automatically which happens on a real device.

Example

To prevent the keyboard from appearing, add the following attribute to the <activity> element in the AndroidManifest.xml file:


<?xml version="1.0" encoding="utf-8"?>
<manifest ...
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="4" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" 
            android:windowSoftInputMode="stateHidden" 
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Note

The code above turns off the soft input panel by using the attribute in <activity> tag as follows.


        <activity
             ...
            android:windowSoftInputMode="stateHidden" 
        >





















Home »
  Android »
    Android Basics »




Hello Android
Resources
Activity
Calendar
Camera
Contact
Content Provider
Database
Hardware
Intent
Location
Media
Network
Notification
Preference
Sensor
Service
SMS