Can't get cursor position from InputConnection

by nattster » Fri, 20 May 2011 09:30:36 GMT


Sponsored Links
 I'm developing an Input Method. 
I'd like to change cursor position with 
*InputConnection.setSelection< http://developer.android.com/reference/android/view/inputmethod/InputConnection.html #setSelection(int,
 
int)>*.

This method allows me to set absolute position of cursor.
But what I want is to move cursor relatively from current position.
(e.g. Move left 3 characters from current position)

I can't find method to get current cursor position.
Currently, I got this hack:

    InputConnection conn;
    CharSequence seq = conn.getTextBeforeCursor(1000, 0); 
    // will get as much characters as possible on the left of cursor

    int cursor_pos = seq.length();

Is there any better way to do this?
Should we introduce new method to InputConnection, i.e. getSelectionStart?

-- 



Other Threads

1. reg AttributeSet

Hello,

I'd like to use a non-compiled file (that I get dynamically from my
server) in order to fetch the AttributeSet for a component. To put it
another way - I'd like to create an AttributeSet at runtime. Is that
possible?

If the only way to do this is by implementing the AttributeSet
interface, then can you please give me some pointers on how to go
about it?

I thought I might use XmlResourceParser class probably, but I am
unable to create an object of XmlResourceParser at runtime with a non-
compiled file.

I am working on Android 2.0.1. I don't mind even if I have to use a
newer SDK(2.1) in order to achieve this.

Please feel free to ask for clarifications in case I haven't put
across my point clearly.

Thanks a lot,
Priyanka

-- 

2. Regarding Tv out in Android

Hi All,
  Is there any TV out feature in Android. Is anyone working on it ?

Thanks and Regards,
 Dileep

-- 

3. Why are my SharedPreferences suddenly deleted, after I updated my game in the Market?

4. Suspicious TCP RST packets while device is sleeping.

5. How to Generate Android Testing Report in HTML Automatically

6. perkenalan....

7. Vertex arrays vs. VBOs