2

The image shows the screenshot of my application. As you can see that the cursor is at the text field pertaining to "Height". Whenever I launch my app the default cursor position is at "Height". I want it to be on "Mass". How do I do it ? I can't figure out. Please help.!

Screenshot

Blue Ice
  • 7,654
  • 5
  • 31
  • 50
CodeWalker
  • 2,145
  • 4
  • 17
  • 43

2 Answers2

1

Take a look at your .xml file:

   <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:ems="10" >

        <requestFocus />

    </EditText>

And set the <requestFocus /> tag appropriately. Also, you can call:

EditText.requestFocus();
Philipp Jahoda
  • 49,738
  • 23
  • 176
  • 183
0

Either update your .xml file as follows.

<EditText 
 android:id=@+id/etMass
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
    <requestFocus/> </EditText>

Or Use Code:

EditText etMass = (EditText) findViewById(R.id.etMass);
etMass.requestFocus();
Sunil Shrestha
  • 278
  • 1
  • 6