項(xiàng)目開發(fā)中遇到一個(gè)問題就是點(diǎn)擊EditText文本框編輯文本時(shí)霍弹,會(huì)出現(xiàn)系統(tǒng)自帶的軟鍵盤楣铁,而我并不需要系統(tǒng)的軟鍵盤使用自己定義的,于是我就在網(wǎng)上查找了一下如何去除系統(tǒng)軟鍵盤的問題娱据,最好用的就是通過反射的方式:如下代碼
public void disableShowSoftInput(){
if(android.os.Build.VERSION.SDK_INT<=14){
numberLabel.setInputType(InputType.TYPE_NULL);
}else{
Class?cls=EditText.class;
Method method;
try{
method=cls.getMethod("setShowSoftInputOnFocus",boolean.class);
method.setAccessible(true);
method.invoke(numberLabel,false);
}catch(Exception e){
}
numberLabel是EditText