protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_news_content); viewFlipperNewsUi = (ViewFlipper) findViewById(R.id.viewflipper_news_ui); inflater = getLayoutInflater(); View rL…
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_news_content); viewFlipperNewsUi = (ViewFlipper) findViewById(R.id.viewflipper_news_ui); inflater = getLayoutInflater(); View rL…
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_news_content); viewFlipperNewsUi = (ViewFlipper) findViewById(R.id.viewflipper_news_ui); inflater = getLayoutInflater(); View rL…
最近在弄一个对话框的登录时,发现一个总是报NullPointerException的错误,折腾了两小时,一直没有发现细小的区别..先上图,一边说明原因 首先是 Activity类中定义的findViewById() * There are two methods almost all subclasses of Activity will implement: * * <ul> * <li> {@link #onCreate} is where you initialize you…
Custom View, 使用的时候是这样的: <com.example.home.alltest.view.MyCustomView android:id="@+id/customView" android:layout_width="match_parent" android:layout_height="wrap_content"> </com.example.home.alltest.view.MyCustomView&…
在做android练习,一个新手错误,记录一下: 在练习android权威编程指南时,第5章 第二个Activity部分练习,出现标题问题,代码还原如下: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mQuestionTitle = (TextView)findViewById(R.id.question_title); mQuestionAnswer = (Te…
一.LayoutInflater 的作用 我们一般使用 LayoutInflater 做一件事:View inflate(int resource, ViewGroup root); inflate() 的作用类似于 findViewById(); 不同的是 findViewById 用于查找某一具体 XML 下的具体的 widget 控件(如 TextView,Button 等待)而 inflate 则用于查找 /res/layout/文件夹下的 XML 布局文件并实例化,与 setConte…
什么是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…
本文结合源代码和实例来说明TabHost的用法. 使用TabHost 可以在一个屏幕间进行不同版面的切换,例如android自带的拨号应用,截图:  查看tabhost的源代码,主要实例变量有: private TabWidget mTabWidget;    private FrameLayout mTabContent;    private List<TabSpec> mTabSpecs  也就是说我们的tabhost必须有这三个东西,所以我们的.xml文件就会有规定:继续查看源代码:…