InputMethonUtils.kt 731 Bytes
Newer Older
1
package com.ydl.ydlcommon.utils
konghaorui committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

import android.content.Context
import android.view.inputmethod.InputMethodManager
import android.widget.EditText

/**
 * 输入法工具类
 * Created by harvie on 2017/6/23 0023.
 */

class InputMethonUtils{

    companion object{
        /**
         * EditText获取焦点并显示软键盘
         */
        fun showSoftInputFromWindow(context : Context,editText: EditText?) {
            editText?.isFocusable = true
            editText?.isFocusableInTouchMode = true
            editText?.requestFocus()
            var input : InputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
            input.showSoftInput(editText,0)
        }
    }

}