This is in response to miannelle The following method is called when a menu option is selected: private void addNote() { final Dialog dialog = new Dialog(this); dialog. SetContentView(R.layout. Textentryalertdialog); dialog.
SetTitle("Add note"); TextView msgText = (TextView) dialog. FindViewById(R.id. Messagetext); msgText.
SetText("Whatever prompt you want"); final EditText inputLine = (EditText) dialog. FindViewById(R.id. My_edittext); Button okButton = (Button) dialog.
FindViewById(R.id. OKButton); okButton. SetOnClickListener(new OnClickListener() { public void onClick(View arg0) { dialog.dismiss(); // app specific code } }); Button cancelButton = (Button) dialog.
FindViewById(R.id. CancelButton); cancelButton. SetOnClickListener(new OnClickListener() { public void onClick(View arg0) { dialog.dismiss(); } }); dialog.getWindow().
SetSoftInputMode(WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.show(); } The textentryalertdialog. Xml file defines a linear layout containing TextView android:id="@+id/messagetext EditText android:id="@+id/my_edittext Button android:id="@+id/OKButton Button android:id="@+id/CancelButton I hope this helps.
This is in response to miannelle. The following method is called when a menu option is selected: private void addNote() { final Dialog dialog = new Dialog(this); dialog. SetContentView(R.layout.
Textentryalertdialog); dialog. SetTitle("Add note"); TextView msgText = (TextView) dialog. FindViewById(R.id.
Messagetext); msgText. SetText("Whatever prompt you want"); final EditText inputLine = (EditText) dialog. FindViewById(R.id.
My_edittext); Button okButton = (Button) dialog. FindViewById(R.id. OKButton); okButton.
SetOnClickListener(new OnClickListener() { public void onClick(View arg0) { dialog.dismiss(); // app specific code } }); Button cancelButton = (Button) dialog. FindViewById(R.id. CancelButton); cancelButton.
SetOnClickListener(new OnClickListener() { public void onClick(View arg0) { dialog.dismiss(); } }); dialog.getWindow(). SetSoftInputMode(WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_VISIBLE); dialog.show(); } The textentryalertdialog.
Xml file defines a linear layout containing TextView android:id="@+id/messagetext" ... EditText android:id="@+id/my_edittext" ... Button android:id="@+id/OKButton" ... Button android:id="@+id/CancelButton" ... I hope this helps.
With the encouragement of Mur Votema (see his answer above) I have answered my question by building a custom dialog based on the Dialog class. Unlike an alert based on AlertDialog. Builder such a custom dialog does accept the getWindow().
SetSoftInputMode(...) command and therefore allows the soft keyboard to be displayed automatically. For guidance on building a custom dialog I found this web page and this especially helpful.
Congratulations! :) – Mur Votema Nov 7 '10 at 10:23 Thanks again to you and everyone else for your help. :) – prepbgg Nov 7 '10 at 20:36.
Thanks for the suggestion. I tried inserting inputBox.requestFocus(); after alert. SetView(inputBox);, but no joy!
– prepbgg Oct 30 '10 at 16:24 ... and if you try to call requestFocus after alert.create()? Because first dialog should be created and then edit can get focus, no?! – Mur Votema Oct 30 '10 at 21:05 My code doesn't explicitly call create().
Presumably it is called indirectly by the statement "AlertDialog. Builder alert = new AlertDialog. Builder(this);" which definitely comes before any other reference to alert.
– prepbgg Oct 30 '10 at 21:15 but is there show()-method somewhere in your code?! – Mur Votema Oct 30 '10 at 22:22 1 With the help of a couple of tutorials (helloandroid. Com/tutorials/… and blog.androgames.
Net/10/custom-android-dialog) I've created a custom Dialog object which emulates the default AlertDialog. Builder object well (so far as I can tell) and which (unlike an AlertDialog. Builder object) accepts the getWindow().
SetSoftInputMode(...) command. Bingo! It wasn't so difficult, I suppose, but it's an extraordinarily fiddly thing to have to do just to allow the automatic display of the soft keyboard.
– prepbgg Oct 30 '107 at 20:54.
As long as you always need to show the keyboard immediately once the dialog opens rather than once a specific form widget inside gets focus (for instance, if your dialog just shows an EditText and a button), you can do the following: AlertDialog alertToShow = alert.create(); alertToShow.getWindow(). SetSoftInputMode(WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_VISIBLE); alertToShow.show(); Rather than calling .show() on your builder immediately, you can instead call .create() which allows you to do some extra processing on it before you display it onto the screen.
Thanks for the suggestion. However, when I try that Eclipse says "the method getWindow() is undefined for type EditText" – prepbgg Oct 30 '10 at 13:18.
Thanks for the suggestion. I tried that, but unfortunately I got the same error message ("the method getWindow() is undefined for the type View") – prepbgg Oct 30 '10 at 16:20.
Prepbgg there is actually an alternative way to what you've done. I actually had to use mine within my ArrayAdapter. What I did was pass the context of the activity into the arrayadapter then call it to access getWindow() something like this: NoteArrayAdapter(Activity _activity, int _layout, ArrayList _notes, Context _context) { callingNoteListObj = (NoteList) _context; } // withiin getView callingNoteListObj.getWindow().
SetSoftInputMode(WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_HIDDEN); // within parent activity's onCreate() thisObject = this; //within my parent activity's fillData() (NoteList) adapter = new NoteArrayAdapter(activity, R.layout. Channel_note_list_item, noteList, thisObject).
I think you almost had it working in your original question. Try creating a final AlertDialog to call getWindow() on, e.g. // Create the dialog used to modify the mailbox alias final AlertDialog dialog = alert.create(); inputBox. SetOnFocusChangeListener(new View.
OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow(). SetSoftInputMode( WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); I've tested this code and the keyboard now appears automatically on most of my devices, including: -Samsung Galaxy Tab OS 2.2 -Samsung Galaxy S OS 2.1 -HTC Sensation OS 2.3.4 Some other comments on this solution: 1) Check if you've got anything in your XML already to request the focus, as that may stop this code working (according to Ted in the question you link to).
2) This code doesn't seem to work on my HTC G2 running OS 2.3.4. I guess this is because it has a physical keyboard, and maybe the WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_VISIBLE option doesn't work with it?
I also tried SOFT_INPUT_STATE_VISIBLE (without the ALWAYS), but that stopped the keyboard appearing automatically. 3) You may also want to add code so the user can press the Done button on the keyboard to submit the changes, e.g.InputAlias. SetOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.
KEYCODE_ENTER && inputAlias.isFocused() && inputAlias.getText().length()! = 0) { // Save the new information here // Dismiss the dialog dialog.dismiss(); return true; } return false; } }).
I think you almost had it working in your original question. Try creating a final AlertDialog to call getWindow() on, e.g. 1) Check if you've got anything in your XML already to request the focus, as that may stop this code working (according to Ted in the question you link to). 2) This code doesn't seem to work on my HTC G2 running OS 2.3.4.
I guess this is because it has a physical keyboard, and maybe the WindowManager.LayoutParams. SOFT_INPUT_STATE_ALWAYS_VISIBLE option doesn't work with it? I also tried SOFT_INPUT_STATE_VISIBLE (without the ALWAYS), but that stopped the keyboard appearing automatically.
3) You may also want to add code so the user can press the Done button on the keyboard to submit the changes, e.g.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.