cannot resolve method ‘get key’ in Pair in android?

Tags: ,



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

Answer

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;


Source: stackoverflow