From 5a91ed9723e1eb49a6d79a166d51279e691dd6d8 Mon Sep 17 00:00:00 2001 From: pelya Date: Thu, 10 Mar 2011 17:54:10 +0200 Subject: [PATCH] Some failed attempts to make EditText widget without autocomplete and showing screen keyboard automatically. --- project/java/MainActivity.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index a89801033..624c72286 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -23,6 +23,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.view.View.OnKeyListener; +import android.text.method.TextKeyListener; import java.util.LinkedList; import java.io.SequenceInputStream; import java.io.BufferedInputStream; @@ -277,10 +278,19 @@ public class MainActivity extends Activity { } }; _screenKeyboard = new EditText(this); + _videoLayout.addView(_screenKeyboard); _screenKeyboard.setOnKeyListener(new myKeyListener(this, sendBackspace)); _screenKeyboard.setHint(R.string.text_edit_click_here); _screenKeyboard.setText(oldText); - _videoLayout.addView(_screenKeyboard); + final Window window = getWindow(); + _screenKeyboard.setOnFocusChangeListener(new View.OnFocusChangeListener() { + public void onFocusChange(View v, boolean hasFocus) + { + if (hasFocus) + window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); + } + }); + _screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false)); _screenKeyboard.setFocusableInTouchMode(true); _screenKeyboard.setFocusable(true); _screenKeyboard.requestFocus();