-2

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??

  • see following post [Android: Copy to clipboard selected text from a TextView](http://stackoverflow.com/questions/6624763/android-copy-to-clipboard-selected-text-from-a-textview) – ρяσѕρєя K Nov 05 '15 at 15:37
  • I have anything to do with this post... I only want to know how to distinguish the selected editText (where tHere is the cursor) and the other ediText.. because I want firstly to set the text in editText 1 and then, with the same button, set the text in editText 2 – Gabriele Marcozzi Nov 05 '15 at 15:41

1 Answers1

1

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?

Community
  • 1
  • 1
Stornu2
  • 2,284
  • 3
  • 27
  • 47