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!
on your button's onClick()
put..
thirdEditText.requestFocus();
Something like,
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
thirdEditText.requestFocus();
}
});
editText3.requestFocus();
add in onClick method of button.
Use requestFocus()
method to gain focus.
Or put < requestFocus/> in your XML layout.
this is the code:
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
edittext.setFocusableInTouchMode(true);
edittext.requestFocus();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With