1

I have been developing a simple Calculator Application in Android Studio. The result window (where the numbers are placed for calculation) I initially set as a TextView. However, I haven't found a way to implement a cursor while using the TextView. My goal is to have the result window display a cursor and have text selectable but not editable. When using EditView I have tried to disable the soft keyboard, disable input, etc., with no success. Can I accomplish this using either an EditView/TextView?

Soft keyboard issue enter image description here

Screenshot enter image description here

I obviously do not want the user to be able to utilize the soft keyboard, but I still want to maintain the cursor and have the text selectable.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Wheat
  • 31
  • 6

2 Answers2

1

To hide keyboard keys in fragment interface use

EditText edt=(EditText)View.findViewById(R.id.editTextForNumbers);
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edt.getWindowToken(), 0);

If it is in an activity use

EditText edt=(EditText)findViewById(R.id.editTextForNumbers);
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edt.getWindowToken(), 0);
Cistem
  • 133
  • 1
  • 2
  • 11
  • This was implemented but still results in the soft keyboard popping up when text is selected. – Wheat Mar 28 '17 at 00:21
0

Set these properties for your edittext or textview

android:cursorVisible="true"
android:textCursorDrawable="@null"
pravin maske
  • 72
  • 1
  • 13