文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>android学习笔记

android学习笔记

时间:2010-12-10  来源:小农

   

tools_text = (TextView) findViewById(R.id.TextView01);
tools_button =(Button) findViewById(R.id.Tools_ok);
tools_radiogroup = (RadioGroup) findViewById(R.id.RadioGroup01); setContentView(R.layout.tools);

 

 将导致tools_text等抛出空指针异常

 

super.onCreate(stateInstanceState);
setContentView(R.layout.tools);
tools_text = (TextView) findViewById(R.id.TextView01);
tools_button =(Button) findViewById(R.id.Tools_ok);
tools_radiogroup = (RadioGroup) findViewById(R.id.RadioGroup01);

 

是正确的写法

小结:空指针异常通常与函数的调用顺序有关,注意检查。

相关阅读 更多 +
排行榜 更多 +
武士刀之战

武士刀之战

休闲益智 下载
闲置肥皂切割

闲置肥皂切割

休闲益智 下载
大航海时代2

大航海时代2

休闲益智 下载