最近在弄一个对话框的登录时,发现一个总是报NullPointerException的错误,折腾了两小时,一直没有发现细小的区别..先上图,一边说明原因 首先是 Activity类中定义的findViewById() * There are two methods almost all subclasses of Activity will implement: * * <ul> * <li> {@link #onCreate} is where you initialize you…
什么是LayoutInflater This class is used to instantiate layout XML file into its corresponding View objects. 这个类作用是把把xml类型的布局转化成相应的View对象 在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById(). 不同点是LayoutInflater是用来找res/layout/下的xml布局文件,并且实例化:而findViewById…
在android应用程序中我们可能需要切换模式,如晚上切换到夜间模式便于阅读等.本文参考了网上的一些资料,并结合实例,实现了动态更改主题的效果. Android中实现theme主题可以使用在activity中使用setTheme(int)的方法,SDK中对此方法的说明为: //Set the base theme for this context. Note that this should be called before any views are instantiated in the C…