Reputation: 31
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?
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.
Upvotes: 1
Views: 155
Reputation: 72
Set these properties for your edittext or textview
android:cursorVisible="true"
android:textCursorDrawable="@null"
Upvotes: 0
Reputation: 133
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);
Upvotes: 1