as we know in TextView
or EditText
after selecting text we have ContextMenu
, my question is: how can i select text without having ContextMenu
or disable showing that?
this code work, but that cause of can't selecting text
public class MyEditText extends AppCompatEditText {
private final Context mContext;
private int mPreviousCursorPosition;
public MyEditText(Context context) {
super(context);
this.mContext = context;
}
public MyEditText(Context context, AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
}
public MyEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mContext = context;
}
@Override
protected void onSelectionChanged(int selStart, int selEnd) {
CharSequence text = getText();
if (text != null) {
if (selStart != selEnd) {
setSelection(selStart, selEnd);
return;
}
}
mPreviousCursorPosition = selStart;
super.onSelectionChanged(selStart, selEnd);
}
}