inflate, findViewById与setContentView的区别与联系 分类: H1_ANDROID 2014-04-18 22:54 1119人阅读 评论(0) 收藏
2014-04-18 22:54
701 查看
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 rLNewsUi = inflater.inflate(R.layout.news_body, null); viewFlipperNewsUi.addView(rLNewsUi); }
1、inflate是用来找layout下布局文件,并实例化;而findViewById是找布局文件下的具体widget。
2、setContentView()一旦调用, layout就会立刻显示UI;而inflate只会把Layout形成一个以view类实现成的对象,有需要时再用setContentView(view)显示出来。
相关文章推荐
- inflate, findViewById与setContentView的区别与联系
- inflate, findViewById与setContentView的区别与联系
- inflate, findViewById与setContentView的区别与联系
- inflate, findViewById与setContentView的区别与联系
- inflate, findViewById与setContentView的区别与联系
- Android中setContentView、addContentView、inflate、LayoutInflater和findViewById()区别
- inflate, findViewById与setContentView的区别与联系
- setContentView、findViewById 和 inflate 的区别?
- setContentView、findViewById 和 inflate 的区别?
- inflate, findViewById与setContentView的差别与联系
- Android] setContentView和inflater区别以及findViewById和inflater的区别
- [Android] setContentView和inflater区别以及findViewById和inflater的区别
- 有关Fragment的getActivity().findViewById,以及inflate与 findViewById 区别、setContentView和inflate的区别!!!
- setImageResource和setImageDrawable区别 分类: Android图形动画 2014-08-31 10:12 138人阅读 评论(0) 收藏
- [Android 界面] setContentView和inflate区别!!!
- Android setContentView和inflate区别
- android 如何把一个 RelativeLayout或ImageView背景设为透明 分类: Android多媒体 2015-01-18 10:37 74人阅读 评论(0) 收藏
- Android TextView文字过多,添加滚动条 分类: Android 2015-07-21 13:39 2人阅读 评论(0) 收藏
- [Android]inflate方法与 findViewById 方法区别 | LayoutInflater的inflate函数用法详解
- Android开发中setContentView和inflate的区别分析