zoukankan      html  css  js  c++  java
  • inflate, findViewById与setContentView的区别与联系 分类: H1_ANDROID 2014-04-18 22:54 1119人阅读 评论(0) 收藏

    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)显示出来。



    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    序列化
    cookie 和 session
    a 标签提交表单
    SpringBoot使用Easypoi导出excel示例
    PDF操作类库 iText
    HandlerInterceptor
    Fastdfs
    InitializingBean
    CORS CorsFilter
    XMLHttpRequest
  • 原文地址:https://www.cnblogs.com/lujinhong2/p/4637349.html
Copyright © 2011-2022 走看看