Recent

Author Topic: LAMW - softinput new calling suggestion  (Read 937 times)

Mongkey

  • Sr. Member
  • ****
  • Posts: 433
LAMW - softinput new calling suggestion
« on: June 16, 2023, 03:34:22 am »
Hello, mr. JMP , i got this code are more easy to control soft keyboard

Code: Java  [Select][+][-]
  1.     public void HideSoftInput(View _view) {
  2.         InputMethodManager imm = (InputMethodManager) controls.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
  3.         if (imm == null) {
  4.             return;
  5.         }
  6.         imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
  7.         //imm.hideSoftInputFromWindow(_view.getWindowToken(), 0);
  8.     }
  9.  
  10.     public void ShowSoftInput() {
  11.         InputMethodManager imm = (InputMethodManager) controls.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
  12.         if (imm == null) {
  13.             return;
  14.         }
  15.         imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,0);
  16.         //imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
  17.         //imm.toggleSoftInput(InputMethodManager.RESULT_SHOWN, 0);
  18.     }
  19.  

Thank You!

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: LAMW - softinput new calling suggestion
« Reply #1 on: June 16, 2023, 07:10:23 am »
Done  as:

Code: Java  [Select][+][-]
  1. public void HideSoftInput()  {  //not parameterized ....
  2.         InputMethodManager imm = (InputMethodManager) controls.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
  3.         if (imm == null) {
  4.             return;
  5.         }
  6.         imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
  7. }
  8.  
  9.  
  10. public void ShowSoftInput() {
  11.       InputMethodManager imm = (InputMethodManager) controls.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
  12.         if (imm == null) {
  13.             return;
  14.         }
  15.         imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,0);
  16. }
  17.  

Yes, maybe you can improve the parameterized,  too

Code: Java  [Select][+][-]
  1. public void HideSoftInput(View _view) {
  2.     //????
  3. }
  4.  


Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Mongkey

  • Sr. Member
  • ****
  • Posts: 433
Re: LAMW - softinput new calling suggestion
« Reply #2 on: June 16, 2023, 11:02:53 am »
 :)

 

TinyPortal © 2005-2018