惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - cjnong

EVA:自定义字段实现 Mac OS 下安装mysqlclient报“mysql_config not found”的解决 Tensorflow之训练MNIST(1) [新手]在macOS环境下安装xdebug 31.8重拾技术人生 MAC下安装MAMP后,mysql server无法启动 用myeclipse配置hibernate 重学JSP—设置CATALINA_HOME环境变量 Java 回调函数 转自:http://blog.sina.com.cn/s/blog_48cf38890100go6x.html 创建一个android activity 启动不了android模拟器 口语考试制作(三)——使用DllImport调用非托管函数 在线口语考试系统制作(二) 在线口语考试制作(一) 网页播放器的控制参数的收集 使用不同版本的.net框架使服务器应用程序不可用 ASP.NET生成静态页面的方法 sql2005转SQL2000出现的问题 实现页面无刷新(使用回调函数) - cjnong - 博客园
android学习笔记
cjnong · 2010-12-10 · via 博客园 - cjnong

1、在activity 的 onCreate()方法,主要用于为创建一个activity完成初始化工作,其中

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);

是正确的写法

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