android editText is cursor visible?
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!!!
}
}
});
精彩评论