Organizational Research By

Surprising Reserch Topic

how do i move cursor to end of edittext line after an orientation change using -'android,android-edittext,android-orientation'


how do i move cursor to end of edittext line after an orientation change  using -'android,android-edittext,android-orientation'

I have an EditText line on a UI screen for a user to enter a sentence.  If the the user leaves the cursor in the middle of the sentence and then does an orientation change, I want the cursor to move to the end of the sentence.  My understanding was that the OS creates a new Activity and new focus on orientation change so I set up the below code, but to no avail.  Please advise.

partial Activity file:

...
cListenerEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
         @Override
         public void onFocusChange(View v, boolean hasFocus) {
             if (hasFocus && (cListenerEditText.getText().length() > 0)) {
                cListenerEditText.setSelection(cListenerEditText.getText().length());
             }
         }
    });

    
asked Sep 8, 2015 by rajesh
0 votes
6 views



Related Hot Questions



Government Jobs Opening


...