Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place cursor to certain EditText box?

Tags:

android

My XML contains Five EditText box and One Button. My cursor is now pointed to the First EditText box. How can I click a button to place the cursor automaticly to Third EditText box.

Thank you!

like image 942
Sekar Avatar asked Jun 27 '12 12:06

Sekar


4 Answers

on your button's onClick() put..

thirdEditText.requestFocus();

Something like,

button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            thirdEditText.requestFocus(); 
        }
    });
like image 72
user370305 Avatar answered Oct 26 '22 03:10

user370305


editText3.requestFocus();

add in onClick method of button.

like image 21
Samir Mangroliya Avatar answered Oct 26 '22 01:10

Samir Mangroliya


Use requestFocus() method to gain focus.

Or put < requestFocus/> in your XML layout.

like image 41
nullpotent Avatar answered Oct 26 '22 02:10

nullpotent


this is the code:

btn.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            edittext.setFocusableInTouchMode(true);
            edittext.requestFocus();

        }
    });
like image 38
Stefano Ortisi Avatar answered Oct 26 '22 02:10

Stefano Ortisi