Perhaps try to completely eliminate the xml attribute android:editable , and then try the following in conjunction with
keep the cursor blinking and to prevent touch events from the built-in IME (keyboard).
public class EditTextEx extends EditText { public EditTextEx(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onCheckIsTextEditor() { return false;
Step 2 modify the above method to say return true;
Step 3 Add another method to the class above.
@Override public boolean isTextSelectable(){ return true; }
Step 4 In another place where an instance of this class was created and called viewB , I added a new touch event handler
viewB.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { viewB.setCursorVisible(true); return false; } });
Step 5 Verify that the XML instance code and / or EditText declares the IME / keyboard type to "none". I did not confirm relevance, but Im also used the attributes below.
<questionably.maybe.too.longofa.packagename.EditTextEx android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:focusable="true" android:focusableInTouchMode="true" android:inputType="none">
Sorry for so many xml attributes. My code uses them all, testing in 4.2.1 and has results.
Hope this helps.
source share