Hello again,
There is also an approach using the InputMethodManager:
EditText text = FindViewById<EditText>(Resource.Id.MyTextView);
ThreadPool.QueueUserWorkItem((s) =>
{
Thread.Sleep(100);
RunOnUiThread(() =>
{
InputMethodManager imm =
(InputMethodManager)GetSystemService(Context.InputMethodService);
imm.ShowSoftInput(text, ShowFlags.Implicit);
});
});
For some reason you have to wait a while before calling it, otherwise
the keyboard won't show right after creating the Activity, not sure
why this is, this thread:
http://stackoverflow.com/questions/5105354/how-to-show-soft-keyboard-when-edittext-is-focused
suggest that this is due to animations disabling the soft keyboard.
On Mon, Apr 23, 2012 at 4:20 PM, Tomasz Cielecki <[email protected]> wrote:
> Ah lol, I didn't see that. Sorry!
>
> I can't seem to find a nice way to do this, but this seems to work:
>
> EditText text = FindViewById<EditText>(Resource.Id.MyTextView);
>
> ThreadPool.QueueUserWorkItem((s) =>
> {
> Thread.Sleep(100);
> RunOnUiThread(() =>
> {
> text.RequestFocus();
>
> text.DispatchTouchEvent(MotionEvent.Obtain(SystemClock.UptimeMillis(),
> SystemClock.UptimeMillis(), MotionEventActions.Down, 0, 0, 0));
>
> text.DispatchTouchEvent(MotionEvent.Obtain(SystemClock.UptimeMillis(),
> SystemClock.UptimeMillis(), MotionEventActions.Up, 0, 0, 0));
> });
> });
>
> This is done in the OnCreate method of the activity. What happens is
> that I request focus on the EditText and simulate a tap on it. There
> is probably a really nice way of doing it otherwise!
>
> On Mon, Apr 23, 2012 at 3:00 PM, Miljenko Cvjetko
> <[email protected]> wrote:
>> Hi Tomasz
>>
>>
>> On 2012.04.23 14:58, Tomasz Cielecki wrote:
>>>
>>> Use UITextFields BecomeFirstResponder() method.
>>>
>>> I.e.:
>>>
>>> UITextField _textField = new UITextField();
>>> _textField.BecomeFirstResponder();
>>> View.AddSubview(_textField);
>>
>> Yup, we are both on m4a and mtch lists, but this time I was asking about
>> m4a and You just gave me sample for mtch.
>>
>> but anyway thanks
>>
>> mel
>>
>>
>>>
>>> On Mon, Apr 23, 2012 at 2:24 PM, Miljenko Cvjetko
>>> <[email protected]> wrote:
>>>>
>>>> Hi
>>>>
>>>> I have single edittext widget in activity layout and would like to show
>>>> keyboard without
>>>> user interaction when activity loads.
>>>>
>>>> This is what I have tried:
>>>> editText1.RequestFocus();
>>>> editText1.RequestFocusFromTouch() ;
>>>> editText1.PerformClick();
>>>>
>>>> but keyboard shows (in emulator) only if user clicks/touches edittext
>>>> control
>>>>
>>>> thanks + regards
>>>>
>>>> mel
>>>>
>>>> --
>>>> Miljenko Cvjetko dipl.ing. ET
>>>> Direktor/CEO
>>>> Projektant rješenja/Solution Architect
>>>> Razvojni programer/Senior developer
>>>> Voditelj projekta/Project Manager
>>>>
>>>> IX južna obala 13
>>>> Kajzerica Zagreb
>>>> T: 385 1 7775555
>>>> M: 385 91 557 447 3
>>>> F: 385 1 7779556
>>>> e: [email protected]
>>>> w: http://www.holisticware.net
>>>>
>>>> _______________________________________________
>>>> Monodroid mailing list
>>>> [email protected]
>>>>
>>>> UNSUBSCRIBE INFORMATION:
>>>> http://lists.ximian.com/mailman/listinfo/monodroid
>>>
>>>
>>>
>>
>>
>> --
>> Miljenko Cvjetko dipl.ing. ET
>> Direktor/CEO
>> Projektant rješenja/Solution Architect
>> Razvojni programer/Senior developer
>> Voditelj projekta/Project Manager
>>
>> IX južna obala 13
>> Kajzerica Zagreb
>> T: 385 1 7775555
>> M: 385 91 557 447 3
>> F: 385 1 7779556
>> e: [email protected]
>> w: http://www.holisticware.net
>>
>
>
>
> --
> Med Venlig Hilsen / With Best Regards
> Tomasz Cielecki
> http://ostebaronen.dk
--
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
http://ostebaronen.dk
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid