Android Soft Keyboard Control popup (very good, self-written, absolutely can use)

Source: Internet
Author: User

Recently in the e-commerce project, due to the constant change in demand, in the relevant output such as text box, request pop-up soft keyboard, if the interface a lot of the next, you need a lot of code, in the idle time, wrote a soft keyboard management class, very good, their own written, personally tried, this is a soft keyboard control singleton mode.

The code is as follows:

Package Com.okdi.ilife.activity.login;import Android.app.activity;import Android.content.context;import Android.view.view;import Android.view.inputmethod.inputmethodmanager;import android.widget.edittext;/** * class function Description: Soft keyboard Management Interface </br> * * @author Yuyahao * @version 1.0 </p> Modify Time:</br> Modify notes:</br> */public class I Nputmanager {Private context context; public static InputManager InputManager; private Inputmethodmanager imm; private I  Nputmanager (Context context) {This.context = context;  Get Inputmethodmanager Example IMM = (Inputmethodmanager) context.getsystemservice (Context.input_method_service); Totleshowsoftinput (); } public static InputManager GetInstances (context context) {if (InputManager = = null) {InputManager = new InputManager (c  Ontext); } return InputManager; }/** * Toggle soft Keyboard display and hide */public void Totleshowsoftinput () {imm.togglesoftinput (inputmethodmanager.show_forced, Inputme THODMANAGER.HIDE_IMPLICIT_ONLY); }/** * Judging soft keyboard popup */public void SHOWSOFTINPUT () {if (!imm.isactive ()) {//Imm.togglesoftinput (0, Inputmethodmanager.result_shown); }}/** * off soft keyboard * for a edtxtview * @param input_email */public void Hidesoftinput (EditText input_email) {if (imm.is  Active ()) {//Turn off the soft keyboard, open the same method, this method is switched on and off state of the Imm.hidesoftinputfromwindow (Input_email.getwindowtoken (), 0); }}/** * for multiple Edtxtview * Close all soft keyboards */public void Hideallsoftinput () {View view = ((Activity) context). GetWindow (  ). Peekdecorview ();  if (view! = null) {Imm.hidesoftinputfromwindow (View.getwindowtoken (), 0); } }}

Sometimes we also need to set the input type of its edittext:

Android:inputtype= "None"--Enter ordinary characters android:inputtype= "text"--Enter ordinary characters android:inputtype= "textcapcharacters"-- Enter normal character android:inputtype= "Textcapwords"--the first letter size android:inputtype= "textcapsentences"--only the initial letter size Android:inputtype = "Textautocorrect"--the first two auto-complete android:inputtype= "Textautocomplete"--the first two auto-complete android:inputtype= "Textmultiline"-- Multi-line input android:inputtype= "textimemultiline"--Input method multiple lines (not necessarily supported) android:inputtype= "Textnosuggestions"--Do not prompt Android: Inputtype= "Texturi"--uri format android:inputtype= "Textemailaddress"--e-mail address format android:inputtype= "Textemailsubject"-- Message subject format android:inputtype= "Textshortmessage"--Short message format android:inputtype= "Textlongmessage"--long message format android:inputtype= " Textpersonname "--name format android:inputtype=" Textpostaladdress "--Postal format android:inputtype=" Textpassword "--Password format android: Inputtype= "Textvisiblepassword"--Password visible format android:inputtype= "Textwebedittext"-text format as a Web Form android:inputtype= " TextFilter "--Text filter format android:inputtype=" textphonetic "--Pinyin input format android:inputtype=" number "--Digital format android:inputtype=" Numbersigned "--Signed digital format android:Inputtype= "Numberdecimal"--floating point format with decimal point android:inputtype= "Phone"--dial pad android:inputtype= "datetime" Android: Inputtype= "Date"--date keyboard android:inputtype= "Time"--temporal keyboard

In this way, we can control it, is not very good ah!

older than always believe :

There is nothing that can't be done, but I can't think of it.

Java code: http://download.csdn.net/detail/androidstarjack/8815693

finally attach your own blog address: older than the blog
Http://blog.csdn.net/androidstarjack

you are welcome to explore and learn with the old

Android Soft Keyboard Control popup (very good, self-written, absolutely can use)

Related Article

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.