android - Android kotlin - 为“父”函数返回 int
问题描述
这是代码
private fun like(id: Int): Int{
val params = RequestParams()
params.put("id", id)
val client = AsyncHttpClient()
client.post("https://www.ttt.com/ttt.php", params, object : JsonHttpResponseHandler()
{
override fun onSuccess(statusCode: Int, headers: Array<Header>?, response: JSONArray?)
{
return 1
}
override fun onFailure(statusCode: Int, headers: Array<Header>?, e: Throwable, response: JSONArray?)
{
return 0
}
})
}
如您所见,like
在获得 API 响应后,我尝试为父函数返回 1 或 0,但错误是:
The integer literal does not conform to the expected type Unit
我找不到类似的问题!我怎样才能做到这一点?
解决方案
推荐阅读
- dart - StreamBuilder 快照始终为 ConnectionState.waiting
- wcf - WCF。如何检查凭据在客户端是否有效?
- javascript - 创建一个具有属性的对象以反映其输入字段名称并分配其值
- javascript - 如何在模板中绑定类似于背景颜色的边框颜色属性
- dart - 使容器在某个点透明
- r - 在 R 中执行 bash 脚本
- findstr - 在指定过滤器 select-string 或 findstr 之前包含文本行
- java - Maven编译器插件找不到本地存储库
- java - 如何在所有微服务中维护相同的 Spring Boot 版本?
- matlab - 如何将 vr-sink(视频查看器)的输出输入 Simulink 中的 Alexnet?