开发者

android editText is cursor visible?

开发者 https://www.devze.com 2023-04-09 21:40 出处:网络
Is there any way to know if on a edit text is visible or not the cursor? I need to 开发者_如何学Goknow so I can adapt a delete method. Thanks

Is there any way to know if on a edit text is visible or not the cursor? I need to 开发者_如何学Goknow so I can adapt a delete method. Thanks


public static final int getSelectionStart (CharSequence text) Since: API Level 1

Return the offset of the selection anchor or cursor, or -1 if there is no selection or cursor.

So if it returns -1 you know there is no cursor.

EDIT:

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        if (hasFocus) {
            // cursor visible!!!
        }
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消