Well, curiouser and curiouser.

I made a very simple test app running under 1.5 on my Hero, with an
activity showing a single EditText, after the SetContentView() call, I
use the ToggleSoftInput as described above.

When I run it, it does not show the keyboard. However (and I found
this by accident), if you then turn it to Landscape, the keyboard
magically appears. And then if you turn it back to Portrait, the
keyboard is still there. Yet it won't appear initially in the Portrait
mode when the app is first opened, which is the behaviour I am after.

Yet if I start the app in Landscape, the keyboard appears, and is
there when I move back to Portrait.

Here is my code:

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.inputmethod.InputMethodManager;

public class TestApp extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        InputMethodManager imm =
                (InputMethodManager)getSystemService
(Context.INPUT_METHOD_SERVICE);
                imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
                InputMethodManager.HIDE_IMPLICIT_ONLY);

    }
}

and the main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
<EditText android:text="EditText01"
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>

Could someone confirm that this works as expected on non-Hero
hardware? Or anyone have any other ideas as to the weird behaviour?




On Sep 22, 1:16 am, Dianne Hackborn <hack...@android.com> wrote:
> Oh also it doesn't show by default if the IME needs to run in fullscreen
> (typically because the device is in landscape).  Both of these are because
> showing the IME is these cases is much more disruptive than showing it when
> the target window can resize nicely to show all of its important UI in
> conjunction with the IME.
>
> On Mon, Sep 21, 2009 at 10:15 AM, Dianne Hackborn <hack...@android.com>wrote:
>
>
>
>
>
> > All I can say is the edit contacts activity in the standard platform does
> > this just fine, using the standard API.  Either you are doing something
> > different than it, or HTC's IME has some different behavior, but I don't
> > know much about either of those.  Do note that normally the system will not
> > show the IME by default if it has to use panning on the target window
> > (instead of resize), and the only way to get around this would be to
> > explicitly show the IME when you receive focus.
>
> > On Mon, Sep 21, 2009 at 6:13 AM, James W <jpbwebs...@gmail.com> wrote:
>
> >> I have exactly the same requirement.
>
> >> Running on a Hero, which only has a soft keyboard. The above code is
> >> copied exactly, yet it doesnt work. The keyboard is not shown no
> >> matter where I put the code, before or after SetContentView().
>
> >> This seems like a pretty standard thing to want to do, is there some
> >> other way of doing this?
>
> >> Thanks in advance..
> >> James
>
> >> On Sep 19, 8:42 am, Dianne Hackborn <hack...@android.com> wrote:
> >> > The G1 has a keyboard, so it works as I said -- the IME is not shown by
> >> > default.  This is a policy decision of the platform.
>
> >> > On a myTouch, since it doesn't have a keyboard, the IME will be shown by
> >> > default in various cases (for example when you enter the edit contacts
> >> > screen) when the app has indicated that is desired with the input
> >> options.
>
> >> > On Fri, Sep 18, 2009 at 4:13 PM, Mike Collins <mike.d.coll...@gmail.com
> >> >wrote:
>
> >> > > The behavior I'm talking about is on a locked G1 with 1.5, I did not
> >> > > expect the
> >> > > emulator to be very useful.
>
> >> > > The behavior on a myTouch (locked, 1.5) is really bizarre.
>
> >> > > I'm beginning to think that I'm going to pull all the soft keyboard
> >> > > code out
> >> > > and let the user do the extra work.
>
> >> > >  mike
>
> >> > --
> >> > Dianne Hackborn
> >> > Android framework engineer
> >> > hack...@android.com
>
> >> > Note: please don't send private questions to me, as I don't have time to
> >> > provide private support, and so won't reply to such e-mails.  All such
> >> > questions should be posted on public forums, where I and others can see
> >> and
> >> > answer them.- Hide quoted text -
>
> >> > - Show quoted text -
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
>
> > Note: please don't send private questions to me, as I don't have time to
> > provide private support, and so won't reply to such e-mails.  All such
> > questions should be posted on public forums, where I and others can see and
> > answer them.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to