Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Focus on the first edtitext in android

I have four edittexts the problem is when i start activity the focus will be on the last edittext , how can i make the focus on the first edittext using xml ? Thanks

like image 340
Dev Avatar asked Sep 19 '11 11:09

Dev


People also ask

How can I detect focused Edittext in Android?

You can use View. OnFocusChangeListener to detect if any view (edittext) gained or lost focus. This goes in your activity or fragment or wherever you have the EditTexts. The .... is just saying that you can put it anywhere else in the class.

What is focusable Android?

Focusable means that it can gain the focus from an input device like a keyboard. Input devices like keyboards cannot decide which view to send its input events to based on the inputs itself, so they send them to the view that has focus.

How do I show soft keyboard when Edittext is focused?

android:windowSoftInputMode="stateAlwaysVisible" -> in manifest File. edittext. requestFocus(); -> in code. This will open soft keyboard on which edit-text has request focus as activity appears.


1 Answers

onCreate(); of Activity

EditText firsteditText=(EditText)findViewById(R.id.first);
EditText secondeditText=(EditText)findViewById(R.id.second);
EditText thirdeditText=(EditText)findViewById(R.id.third);
EditText fourtheditText=(EditText)findViewById(R.id.fourth);

     firsteditText.requestFocus();
like image 80
Mohammed Azharuddin Shaikh Avatar answered Oct 20 '22 13:10

Mohammed Azharuddin Shaikh