标签:prot color null bundle 完全 man extend log visio
在你的Activity的onCreate
函数中添加如下代码即可完全禁用软键盘:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
所以,你想全局生效的话,可以写一个基类,例如:
public abstract class BaseNoIMActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); onCreateStarted(savedInstanceState); } protected abstract void onCreateStarted(@Nullable Bundle savedInstanceState); }
然后任意个Activity都继承它,如果你的项目已经有基类,那么把上面的代码插入到基类中即可,demo示例:
public class TestActivity extends BaseNoIMActivity {//继承基类 @Override protected void onCreateStarted(@Nullable Bundle savedInstanceState) { setContentView(R.layout.activity_test); Log.e("test","TestActivity is started"); } }
引用自:https://segmentfault.com/q/1010000008489927/a-1020000008490261/revision
标签:prot color null bundle 完全 man extend log visio
原文地址:http://www.cnblogs.com/linfenghp/p/7874768.html