setContentView()与LayoutInflater.inflate()作用

@Override
 protected void onCreate(Bundle savedInstanceState) {
  try{
   super.onCreate(savedInstanceState);
   setContentView(R.layout.jzxt_main);
   loadView();
   if(BS.client == null) new LoginValidat().execute();
  }catch (Exception e) {
   BS.pb.outErrorLog(this, "oncreat", e);
  }
  
 }

上述代码中setContentView(R.layout.jzxt_main)作用就是相当于LayoutInflater.inflate()的作用:

即,将布局文件转换为可操作的view对象(实例),才能引用view类的一系列方法,从而达到对布局文件xml中的各个组件实例化(简单的findViewById()方法)

 

posted @ 2015-06-07 15:54  一汪海洋  阅读(587)  评论(0编辑  收藏  举报