Hide Software Input Keyboard

Step 1 :Follow the first 7 steps of Static and Dynamic TextView Creation Application.
 
Step 2 :Add the following Code to activity_main.xml :
 
<RelativeLayoutxmlns:android=http://schemas.android.com/apk/res/android&#8221;
android:layout_width=“match_parent”
android:layout_height=“match_parent” >
<EditText
android:id=“@+id/editText1”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_alignParentTop=“true”
android:layout_centerHorizontal=“true”
android:layout_marginTop=“118dp”
android:ems=“10”
android:inputType=“textPersonName” >
<requestFocus />
</EditText>
</RelativeLayout>
 
 
Step 3 :Add the following code to AndroidManifest.xml
<activity
android:name=“.MainActivity”
android:windowSoftInputMode=“stateHidden”
android:label=“@string/title_activity_main” >
<intent-filter>
<action android:name=“android.intent.action.MAIN” />
<category android:name=“android.intent.category.LAUNCHER” />
</intent-filter>
</activity>

 

 
Step 4 :Add the following code to mainActivity.java :
package com.example.xxx;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
publicclass MainActivity extends Activity
{
/** Called when the activity is first created. */
List<String> list;
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText et=(EditText) findViewById(R.id.editText1);
/** Hide keyboard Dynamically
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
*/
}
}
 
Step 5 : Now you can save and execute the Application. Your output will be like this :
 
 
Let’s continue your play with Android…
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s