无法在 Android 中的 Pair 中解析方法 ‘get key’。

huangapple go评论67阅读模式
英文:

cannot resolve method 'get key' in Pair in android?

问题

我在使用Android Studio中的函数时遇到了问题,其中我使用了Pair库中的函数,以下是我的代码片段:

import android.util.Pair;
Penyakit penyakit = (Penyakit) p.getKey();

我需要一个解决方案,谢谢。

英文:

I have a problem using functions in Android Studio, where i use the function in Pair library,here's a snippet of my code

import android.util.Pair;
Penyakit penyakit = (Penyakit) p.getKey();    

i need a solution, thanks

答案1

得分: 0

因为在 android.util.Pair 中没有 #geyKey。您需要使用 pair 的属性,即 firstsecond。在这里,p.first 将是键,p.second 将是值。

Penyakit penyakit = (Penyakit) p.first;
英文:

Because there is not a #geyKey in android.util.Pair . You need use property of pair which are first and second. Here p.first will be key and p.second will be value

        Penyakit penyakit = (Penyakit) p.first;

huangapple
  • 本文由 发表于 2020年9月13日 19:42:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63870338.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定