Maybe try leaving out the xml attribute android:editable
entirely and then try the following in combination to
keep the cursor blinking and prevent touch events from popping up a native IME(keyboard)..
/*customized edittext class
* for being typed in by private-to-your-app custom keyboard.
* borrowed from poster at http://stackoverflow.com/questions/4131448/android-how-to-turn-off-ime-for-an-edittext
*/
public class EditTextEx extends EditText {
public EditTextEx(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onCheckIsTextEditor() {
return false; //for some reason False leads to cursor never blinking or being visible even if setCursorVisible(true) was called in code.
}
}
Step 2
change the above method to say return true;
Step 3
Add another method to above class.
@Override
public boolean isTextSelectable(){
return true;
}
Step 4
In the other location where the instance of this class has been instantiated 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 Check to make sure XML and or EditText instantiation code declares IME/keyboard type to be 'none'. I didnt confirm relevance, but Im also using the focusable 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.
android:inputType="none"
. However, now that I think of this, I don't think it's possible. It doesn't make a whole lot of sense for the developers to make such a thing possible. I would suggest you make a customTextView
class with your own touch listener. – Eric Oct 13 '12 at 6:36TextWatcher
for EditText ?? – ρяσѕρєя K Oct 13 '12 at 6:38EditText
of some kind. – Eric Oct 13 '12 at 7:17