最近忽然对android感兴趣了,于是就找个教材看了看,顿时傻眼了,里面的代码完全颠覆了我以前对java的认知了。
(1)
Button button = (Button) this.findViewById(R.id.button);
如果说是:Button button =this.findViewById(R.id.button);
倒是符合我的认知。
那行代码我明白是什么意思 但不知道为什么这样写?
(2)
for(String text : texts){manager.sendTextMessage(number, null, text, null, null);}
我印象里的for格式是:for (int i = 1; i <= row; i++)这样的吧
这种写法叫什么名字,和前一种写法有什么不同?哪位老师能帮我解释一下。谢谢!
(1)
Button button = (Button) this.findViewById(R.id.button);
如果说是:Button button =this.findViewById(R.id.button);
倒是符合我的认知。
那行代码我明白是什么意思 但不知道为什么这样写?
(2)
for(String text : texts){manager.sendTextMessage(number, null, text, null, null);}
我印象里的for格式是:for (int i = 1; i <= row; i++)这样的吧
这种写法叫什么名字,和前一种写法有什么不同?哪位老师能帮我解释一下。谢谢!
解决方案 »
- 关于反正切函数中正切值可能是无穷大的情况时
- 数据上网 和 wifi 的区别
- paypal在Android设备中的嵌入方式(移动支付解决方案)
- (新手求教)ListPreference 如何默认选中? 如何调用系统的清理数据?
- android中有关NFC的驱动
- Android开发入手准备工作有哪些?
- 请问有android的视频教程了吗?
- android handler 同时处理多条消息
- 第一个android程序就报错,情何以堪(has stopped)
- Android studio新人求助
- Android调用ZXxing 程序意外终止,求助!!!!
- 很奇怪:android中使用socket出现异常setsockopt failed: EBADF (Bad file number)
View view = this.findViewById(R.id.button);2. 这是java的for each语法
foreach (int a in fibarray)
{
System.Console.WriteLine(a);
}
foreach循环的写法是JAVA1.5新加入的,不过这种写法要注意应用场合,有同步隐患
2、是增强for循环 是java1.5新加入的
他们的用法相同,按照业务需求选择使用相应的逻辑语句。
Button button = (Button) this.findViewById(R.id.button);
button.setOnClickListner其实这些都是View的方法啊,不用转换就可以,呵呵
findViewById(R.id.button).setOnClickListner
View view = this.findViewById(R.id.button);
Button button = view
很少用java,所以我对java的认识还停留在多年前写简单网页的javascript上,落伍了。