Howto capture the 'virtual keyboard show/hide' event in Android?

You've got to handle configuration changes your self developer.android.com/guide/topics/resou... Sample: from the link above @Override public void onConfigurationChanged(Configuration newConfig) { super. OnConfigurationChanged(newConfig); // Checks whether a hardware keyboard is available if (newConfig. HardKeyboardHARDKEYBOARDHIDDEN_NO) { Toast.

MakeText(this, "keyboard visible", Toast. LENGTH_SHORT).show(); } else if (newConfig. HardKeyboard HARDKEYBOARDHIDDEN_YES) { Toast.

MakeText(this, "keyboard hidden", Toast. LENGTH_SHORT).show(); } } Then, just change the visibility of some views, update a field, change the layout file you are using or anything else.

You've got to handle configuration changes your self. developer.android.com/guide/topics/resou... Sample: // from the link above @Override public void onConfigurationChanged(Configuration newConfig) { super. OnConfigurationChanged(newConfig); // Checks whether a hardware keyboard is available if (newConfig.

HardKeyboard HARDKEYBOARDHIDDEN_NO) { Toast. MakeText(this, "keyboard visible", Toast. LENGTH_SHORT).show(); } else if (newConfig.

HardKeyboard HARDKEYBOARDHIDDEN_YES) { Toast. MakeText(this, "keyboard hidden", Toast. LENGTH_SHORT).show(); } } Then, just change the visibility of some views, update a field, change the layout file you are using or anything else.

Thank you very much! – Sander Versluys Dec 7 '10 at 14:33 1 it only works for hard keyboard, not soft keyboard – shiami Feb 9 at 2:08 2 @shiami try newConfig. KeyboardKEYBOARDHIDDEN_NO ~Chris – cimnine Aug 7 at 23:17 This only works if you've registered the activity to listen to the configChanges you want in the AndroidManifest.

– Raul Agrait Aug 18 at 23:58 configurationChange does not work for SOFT keyboards. – aatdark Aug 25 at 23:10.

Sander ,I believe you are trying to show the view blocked by the soft keyboard. Try this android-developers.blogspot.com/2009/04/....

The first trackback on this URL points at RussenReaktor's weblog which mentions adding android:windowSoftInputMode="adjustPan" to the Activity's manifest. This worked great for me. – JohnnyLambada Oct 31 at 16:32.

If you want to handle show/hide of IMM (virtual) keyboard window from your Activity, you'll need to subclass your layout and override onMesure method(so that you can determine the measured width and the measured height of your layout). After that set subclassed layout as main view for your Activity by setContentView(). Now you'll be able to handle IMM show/hide window events.

If this sounds complicated, it's not that really. Here's the code: main. Xml Now inside your Activity declare subclass for your layout (main.

Xml) public class MainSearchLayout extends LinearLayout { public MainSearchLayout(Context context, AttributeSet attributeSet) { super(context, attributeSet); LayoutInflater inflater = (LayoutInflater) context. GetSystemService(Context. LAYOUT_INFLATER_SERVICE); inflater.

Inflate(R.layout. Main, this); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { Log. D("Search Layout", "Handling Keyboard Window shown"); final int proposedheight = MeasureSpec.

GetSize(heightMeasureSpec); final int actualHeight = getHeight(); if (actualHeight > proposedheight){ // Keyboard is shown } else { // Keyboard is hidden } super. OnMeasure(widthMeasureSpec, heightMeasureSpec); } } You can see from the code that we inflate layout for our Activity in subclass constructor inflater. Inflate(R.layout.

Main, this); And now just set content view of subclassed layout for our Activity. Public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.

OnCreate(savedInstanceState); MainSearchLayout searchLayout = new MainSearchLayout(this, null); setContentView(searchLayout); } // rest of the Activity code and subclassed layout... }.

If you want to handle show/hide of IMM (virtual) keyboard window from your Activity, you'll need to subclass your layout and override onMesure method(so that you can determine the measured width and the measured height of your layout). After that set subclassed layout as main view for your Activity by setContentView(). Now you'll be able to handle IMM show/hide window events.

If this sounds complicated, it's not that really. Now inside your Activity declare subclass for your layout (main.

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.

Related Questions