3

I have a problem. In the first Activity of my app I have an EditText at the very top of the page inside a linear layout. Problem is that when i run my app, always the EditText is selected for which a keyboard appears on the screen. Is there any way to tell the app not to have the EditText already selected when the app runs? Thanks in advance, Waiting for your reply...

4 Answers4

2

use this code..whenever your project is on, edit-text selected. you will type instantly..

     <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:ems="10" >
     </EditText>
harikrishnan
  • 1,985
  • 4
  • 32
  • 63
2

You can make a method and call it on onCreate() method:

public static void hideSoftKeyboard (Activity activity, View view) {
 InputMethodManager imm =(InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
 imm.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);}

or simply you can add in manifest file like this:

<activity android:name="com.your.package.ActivityName"
      android:windowSoftInputMode="stateHidden"  />
Shani Goriwal
  • 2,111
  • 1
  • 18
  • 30
1

Remove <requestfocus /> from your <EditText /> in XML file.. Request focus means it is gain focus on particulat component.. So remove it...

0

put a <requestFocus /> in your xml.

Example :

<Button ...> 

<requestFocus />

</Button>

It should be on something other than your EditText