@@ -2311,6 +2311,27 @@ public void setHighlightColor(int color) {
23112311 }
23122312 }
23132313
2314+ /**
2315+ * Sets whether the soft input method will be made visible when this
2316+ * TextView gets focused. The default is true.
2317+ * @hide
2318+ */
2319+ @ android .view .RemotableViewMethod
2320+ public final void setShowSoftInputOnFocus (boolean show ) {
2321+ createEditorIfNeeded ("setShowSoftInputOnFocus" );
2322+ mEditor .mShowSoftInputOnFocus = show ;
2323+ }
2324+
2325+ /**
2326+ * Returns whether the soft input method will be made visible when this
2327+ * TextView gets focused. The default is true.
2328+ * @hide
2329+ */
2330+ public final boolean getShowSoftInputOnFocus () {
2331+ // When there is no Editor, return default true value
2332+ return mEditor == null || mEditor .mShowSoftInputOnFocus ;
2333+ }
2334+
23142335 /**
23152336 * Gives the text a shadow of the specified radius and color, the specified
23162337 * distance from its normal position.
@@ -4981,7 +5002,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
49815002 && mLayout != null && onCheckIsTextEditor ()) {
49825003 InputMethodManager imm = InputMethodManager .peekInstance ();
49835004 viewClicked (imm );
4984- if (imm != null ) {
5005+ if (imm != null && getShowSoftInputOnFocus () ) {
49855006 imm .showSoftInput (this , 0 );
49865007 }
49875008 }
@@ -7014,7 +7035,7 @@ public boolean onTouchEvent(MotionEvent event) {
70147035 // Show the IME, except when selecting in read-only text.
70157036 final InputMethodManager imm = InputMethodManager .peekInstance ();
70167037 viewClicked (imm );
7017- if (!textIsSelectable ) {
7038+ if (!textIsSelectable && mEditor . mShowSoftInputOnFocus ) {
70187039 handled |= imm != null && imm .showSoftInput (this , 0 );
70197040 }
70207041
0 commit comments