简体   繁体   中英

how to change a text of selected EditText (android)

I have 2 EditText and a button. When I click the button I want to print a text in the editText which is selected.. How I can do this??

Try to use this:

Get Cursor Position in Android in Edit Text?

In your onClick ask for the myEditText.getSelectionStart(); if is not null thats your EditText.

I hope this helps.

UPDATE

It looks more complicated than i thought at first, you are looking for a focus state. See if any of this answers helps you.

How can I detect focused EditText in android?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM