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

推荐订阅源

Security Latest
Security Latest
Recent Commits to openclaw:main
Recent Commits to openclaw:main
O
OpenAI News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Help Net Security
Help Net Security
V2EX - 技术
V2EX - 技术
W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园_首页
博客园 - 司徒正美
The Cloudflare Blog
D
DataBreaches.Net
Jina AI
Jina AI
L
LINUX DO - 热门话题
宝玉的分享
宝玉的分享
Project Zero
Project Zero
量子位
Spread Privacy
Spread Privacy
Cisco Talos Blog
Cisco Talos Blog
J
Java Code Geeks
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
AI
AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
Attack and Defense Labs
Attack and Defense Labs
V
V2EX
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
Cyberwarzone
Cyberwarzone

博客园 - 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);

是正确的写法

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