文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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);

 

是正确的写法

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

相关阅读 更多 +
排行榜 更多 +
单挑幸存者安卓版

单挑幸存者安卓版

飞行射击 下载
决战战地指挥官

决战战地指挥官

飞行射击 下载
鸡仔幸存者最新版

鸡仔幸存者最新版

飞行射击 下载