diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-01-31 20:14:48 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-01-31 20:14:48 +0100 |
| commit | f732128461e6653b9fdd98865b9efed43fd75d9e (patch) | |
| tree | ba5bc38dd9d1e853c5e31c7580190898d5fd4e02 /main/src/cgeo/geocaching/activity/Keyboard.java | |
| parent | 0ab24e4e2a4033c34b62a4b6864958e78513592e (diff) | |
| download | cgeo-f732128461e6653b9fdd98865b9efed43fd75d9e.zip cgeo-f732128461e6653b9fdd98865b9efed43fd75d9e.tar.gz cgeo-f732128461e6653b9fdd98865b9efed43fd75d9e.tar.bz2 | |
fix #3577: show keyboard on edit note
Diffstat (limited to 'main/src/cgeo/geocaching/activity/Keyboard.java')
| -rw-r--r-- | main/src/cgeo/geocaching/activity/Keyboard.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/activity/Keyboard.java b/main/src/cgeo/geocaching/activity/Keyboard.java new file mode 100644 index 0000000..9bae7be --- /dev/null +++ b/main/src/cgeo/geocaching/activity/Keyboard.java @@ -0,0 +1,40 @@ +package cgeo.geocaching.activity; + +import org.eclipse.jdt.annotation.NonNull; + +import android.app.Activity; +import android.content.Context; +import android.view.View; +import android.view.inputmethod.InputMethodManager; + +/** + * Class for hiding/showing the soft keyboard on Android. + * + */ +public class Keyboard { + private final Activity activity; + + public Keyboard(final @NonNull Activity activity) { + this.activity = activity; + } + + public void hide() { + ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); + } + + public void show(final View view) { + view.requestFocus(); + ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0); + } + + public void showDelayed(final View view) { + view.postDelayed(new Runnable() { + + @Override + public void run() { + final InputMethodManager keyboard = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + keyboard.showSoftInput(view, 0); + } + }, 50); + } +} |
