Android Dynamic Display and hiding of soft keyboards and android dynamic

Source: Internet
Author: User

Android Dynamic Display and hiding of soft keyboards and android dynamic

* ** Dynamically display and hide a floppy disk * @ author JPH */public class MainActivity extends Activity implements OnClickListener {private InputMethodManager inputMethodManager; private Timer timer; private EditText edit; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); edit = (EditText) findViewById (R. id. edit); inputMethodManager = (InputMethodManager) getSystemService (Context. INPUT_METHOD_SERVICE); timer = new Timer (); timer. schedule (new TimerTask () {@ Override public void run () {inputMethodManager. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS); }}, 1000) ;}@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubswitch (v. getId () {case R. id. btnShow: // display the floppy disk inputMethodManager. toggleSoftInput (0, InputMethodManager. HIDE_NOT_ALWAYS); break; case R. id. btnHide: // hide the floppy disk inputMethodManager. hideSoftInputFromWindow (edit. getWindowToken (), InputMethodManager. HIDE_NOT_ALWAYS); break; default: break ;}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.