android - 如何在 Kotlin 中将 View 转换为 Imageview
问题描述
fun tap(view: View) {
val img = view
}
我希望这个变量 img 是一个图像视图,但我想知道如何将视图转换为图像视图。
解决方案
请尝试如下投射:
val img: ImageView = view as ImageView
推荐阅读
- asp.net-core - 如何为 SignInManager 设置模拟模式
在 .net 核心中 - angular - 获取可分配给类型参数的错误
- excel - 在存储在另一个文件中的 CSV 文件上运行宏
- php - 如果给出 PHP "N" 日期值,则查找每周事件的下一次重复
- c# - 如何将我的数组元素显示到文本框中?
- ios - iOS Swift 中的自定义导航栏
- ios - 重新排序 UITableView 中的部分
- python - pygame 多线程客户端套接字 GUI 阻塞
- api - 如何使用从 API 上传的 Yii2 getInstancesByName 验证文件?
- elasticsearch - 将kafka中创建的主题自动下沉到elasticsearch