【发布时间】:2015-05-29 08:49:02
【问题描述】:
Button buttonClick = (Button) findViewById(R.id.button)
应用Java语法,上面的语句表示方法返回的值 findViewById() 更改为数据类型Button,并存储在变量buttonClick中。
我研究过 Java(显然还不够!),但从未遇到过对用户定义的数据类型进行类型转换的情况。 这是如何工作的?
【问题讨论】:
-
它的工作方式与任何其他铸造相同。谁编写的课程并不重要。
-
这是可行的,因为 Button 扩展了 View,它是从 findViewById 返回的
标签: java android type-conversion