注释参数必须是一个编译时间常数-Kotlin
我想在我的主动脉上从覆盖功能中发送一个参数,以在接口上使用,以每次我单击下拉列表时都会更改URL。
On my MainActivity i have:
before the class definition:
var item2:String="popular"
class MainActivity : AppCompatActivity(),AdapterView.OnItemClickListener {
on the same activity:
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long)
{
val item = parent?.getItemAtPosition(position).toString()
item2=item
}
and in the interface:
val get_url:String ="/3/movie/$item2?api_key=KEY_NUMBER"
interface MovieApiInterface {
@GET(get_url)
fun getMovieList(): Call<MovieResponse>
}
But there i have "An annotation argument must be a compile-time constant"
Don't understand why :(
Thanks
I wanna send an argument from an override function on my MainActivity to use on an interface to changue an URL everytime that i made click on a drop down list.
On my MainActivity i have:
before the class definition:
var item2:String="popular"
class MainActivity : AppCompatActivity(),AdapterView.OnItemClickListener {
on the same activity:
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long)
{
val item = parent?.getItemAtPosition(position).toString()
item2=item
}
and in the interface:
val get_url:String ="/3/movie/$item2?api_key=KEY_NUMBER"
interface MovieApiInterface {
@GET(get_url)
fun getMovieList(): Call<MovieResponse>
}
But there i have "An annotation argument must be a compile-time constant"
Don't understand why :(
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误消息实际上是描述性的,您只能将编译时常数作为参数传递给注释,因此您需要替换
:
The error message is actually pretty descriptive, you can only pass compile-time constants as arguments to annotations, so you'll need to replace:
with: