改造 Kotlin RecyclerView 问题...我只能显示 1 个元素...Json GSON 列表有 1 个大小
我无法生成用于显示 recyclerView 中所有元素的真实代码...或者当我在 RecyclerAdapter 上使用此代码时只能显示 1 个元素 - holder.tvValueName.text = currentItem.AMD.Name
但是当我想添加此代码的所有元素时 - holder.tvValueName.text = currentItem.currencyModel.Name
- 它不起作用...... 我已经尝试更改某些类的类型,例如 val valute: Valute -to- val valute:List
然后使用方法 holder.tvValueName.text = currentItem.currencyModel.get(position).Name
获取值 - 但我在 ARRAY 中遇到错误...
如果有人有任何想法请帮忙,提前致谢
interface ApiInterface {
@GET("daily_json.js")
fun getValuteData() : Call<Main>
companion object {
var BASE_URL = "https://www.cbr-xml-daily.ru/"
fun create() : ApiInterface {
val retrofit = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
.build()
return retrofit.create(ApiInterface::class.java)
}
}
}
class RecyclerAdapter(val context: Context) : RecyclerView.Adapter<RecyclerAdapter.MyViewHolder>() {
var valuteItemList : MutableList<Valute> = mutableListOf()
private var changedData: MutableList<Valute> = mutableListOf()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_adapter,parent,false)
return MyViewHolder(view)
}
override fun getItemCount(): Int {
return changedData.size
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val currentItem = changedData[position]
holder.tvValueName.text = currentItem.AMD.Name
holder.tvValueName.text = currentItem.currencyModel.Name
}
@SuppressLint("NotifyDataSetChanged")
fun setValuteListItems(valuteList: MutableList<Valute>){
valuteItemList.clear()
valuteItemList.addAll(valuteList)
changedData.addAll(valuteItemList)
notifyDataSetChanged()
}
class MyViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {
val tvValueName: TextView = itemView!!.findViewById(R.id.title)
val tvValuteValue: TextView = itemView!!.findViewById(R.id.valute_value)
val tvValuteCharCode: TextView = itemView!!.findViewById(R.id.chare_code)
val image: ImageView = itemView!!.findViewById(R.id.image)
}
}
class MainActivity : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
lateinit var recyclerAdapter: RecyclerAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
recyclerView = findViewById(R.id.recyclerview)
recyclerAdapter = RecyclerAdapter(this)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = recyclerAdapter
val apiInterface = ApiInterface.create().getValuteData()
apiInterface.enqueue( object : Callback<Main> {
override fun onResponse(call: Call<Main>?, response: Response<Main>?) {
Log.d("MyTag","Success ")
if(response!!.body() != null)
//recyclerAdapter.setValuteListItems(response.body()!!.Valute as MutableList<Valute>)
recyclerAdapter.setValuteListItems(mutableListOf(response.body()!!.Valute))
Log.d("MyTag","Success "+response.body().toString())
}
override fun onFailure(call: Call<Main>?, t: Throwable?) {
Log.d("MyTag", "Failure "+t.toString())
}
})
}
}
整个 JSON 模型
data class Main(
val Date: String,
val PreviousDate: String,
val PreviousURL: String,
val Timestamp: String,
val Valute: Valute
)
data class CurrencyModel(
val CharCode: String,
val ID: String,
val Name: String,
val Nominal: Int,
val NumCode: String,
val Previous: Double,
val Value: Double
)
data class Valute(
val currencyModel: CurrencyModel,
val AMD: CurrencyModel,
val AUD: CurrencyModel,
val AZN: CurrencyModel,
val BGN: CurrencyModel,
val BRL: CurrencyModel,
val BYN: CurrencyModel,
val CAD: CurrencyModel,
val CHF: CurrencyModel,
val CNY: CurrencyModel,
val CZK: CurrencyModel,
val DKK: CurrencyModel,
val EUR: CurrencyModel,
val GBP: CurrencyModel,
val HKD: CurrencyModel,
val HUF: CurrencyModel,
val INR: CurrencyModel,
val JPY: CurrencyModel,
val KGS: CurrencyModel,
val KRW: CurrencyModel,
val KZT: CurrencyModel,
val MDL: CurrencyModel,
val NOK: CurrencyModel,
val PLN: CurrencyModel,
val RON: CurrencyModel,
val SEK: CurrencyModel,
val SGD: CurrencyModel,
val TJS: CurrencyModel,
val TMT: CurrencyModel,
val TRY: CurrencyModel,
val UAH: CurrencyModel,
val USD: CurrencyModel,
val UZS: CurrencyModel,
val XDR: CurrencyModel,
val ZAR: CurrencyModel
)
JSON
{
"Date": "2022-03-02T11:30:00+03:00",
"PreviousDate": "2022-03-01T11:30:00+03:00",
"PreviousURL": "\/\/www.cbr-xml-daily.ru\/archive\/2022\/03\/01\/daily_json.js",
"Timestamp": "2022-03-01T18:00:00+03:00",
"Valute": {
"AUD": {
"ID": "R01010",
"NumCode": "036",
"CharCode": "AUD",
"Nominal": 1,
"Name": "Австралийский доллар",
"Value": 66.7817,
"Previous": 67.3624
},
"AZN": {
"ID": "R01020A",
"NumCode": "944",
"CharCode": "AZN",
"Nominal": 1,
"Name": "Азербайджанский манат",
"Value": 53.9998,
"Previous": 55.067
},
"GBP": {
"ID": "R01035",
"NumCode": "826",
"CharCode": "GBP",
"Nominal": 1,
"Name": "Фунт стерлингов Соединенного королевства",
"Value": 123.1411,
"Previous": 125.0415
},
"AMD": {
"ID": "R01060",
"NumCode": "051",
"CharCode": "AMD",
"Nominal": 100,
"Name": "Армянских драмов",
"Value": 18.8196,
"Previous": 19.524
},
"BYN": {
"ID": "R01090B",
"NumCode": "933",
"CharCode": "BYN",
"Nominal": 1,
"Name": "Белорусский рубль",
"Value": 29.4765,
"Previous": 33.9264
},
"BGN": {
"ID": "R01100",
"NumCode": "975",
"CharCode": "BGN",
"Nominal": 1,
"Name": "Болгарский лев",
"Value": 52.5944,
"Previous": 53.4592
},
"BRL": {
"ID": "R01115",
"NumCode": "986",
"CharCode": "BRL",
"Nominal": 1,
"Name": "Бразильский реал",
"Value": 17.7795,
"Previous": 18.1182
},
"HUF": {
"ID": "R01135",
"NumCode": "348",
"CharCode": "HUF",
"Nominal": 100,
"Name": "Венгерских форинтов",
"Value": 27.7437,
"Previous": 28.0932
},
"HKD": {
"ID": "R01200",
"NumCode": "344",
"CharCode": "HKD",
"Nominal": 1,
"Name": "Гонконгский доллар",
"Value": 11.7413,
"Previous": 11.9737
},
"DKK": {
"ID": "R01215",
"NumCode": "208",
"CharCode": "DKK",
"Nominal": 1,
"Name": "Датская крона",
"Value": 13.8309,
"Previous": 14.0504
},
"USD": {
"ID": "R01235",
"NumCode": "840",
"CharCode": "USD",
"Nominal": 1,
"Name": "Доллар США",
"Value": 91.7457,
"Previous": 93.5589
},
"EUR": {
"ID": "R01239",
"NumCode": "978",
"CharCode": "EUR",
"Nominal": 1,
"Name": "Евро",
"Value": 102.9112,
"Previous": 104.4772
},
"INR": {
"ID": "R01270",
"NumCode": "356",
"CharCode": "INR",
"Nominal": 10,
"Name": "Индийских рупий",
"Value": 12.1817,
"Previous": 12.3927
},
"KZT": {
"ID": "R01335",
"NumCode": "398",
"CharCode": "KZT",
"Nominal": 100,
"Name": "Казахстанских тенге",
"Value": 18.6621,
"Previous": 18.8393
},
"CAD": {
"ID": "R01350",
"NumCode": "124",
"CharCode": "CAD",
"Nominal": 1,
"Name": "Канадский доллар",
"Value": 72.4346,
"Previous": 73.2646
},
"KGS": {
"ID": "R01370",
"NumCode": "417",
"CharCode": "KGS",
"Nominal": 10,
"Name": "Киргизских сомов",
"Value": 10.7936,
"Previous": 11.0069
},
"CNY": {
"ID": "R01375",
"NumCode": "156",
"CharCode": "CNY",
"Nominal": 1,
"Name": "Китайский юань",
"Value": 14.534,
"Previous": 14.8243
},
"MDL": {
"ID": "R01500",
"NumCode": "498",
"CharCode": "MDL",
"Nominal": 10,
"Name": "Молдавских леев",
"Value": 49.8618,
"Previous": 50.8472
},
"NOK": {
"ID": "R01535",
"NumCode": "578",
"CharCode": "NOK",
"Nominal": 1,
"Name": "Норвежская крона",
"Value": 10.4292,
"Previous": 10.4927
},
"PLN": {
"ID": "R01565",
"NumCode": "985",
"CharCode": "PLN",
"Nominal": 1,
"Name": "Польский злотый",
"Value": 21.9288,
"Previous": 22.2151
},
"RON": {
"ID": "R01585F",
"NumCode": "946",
"CharCode": "RON",
"Nominal": 1,
"Name": "Румынский лей",
"Value": 20.7899,
"Previous": 21.1342
},
"XDR": {
"ID": "R01589",
"NumCode": "960",
"CharCode": "XDR",
"Nominal": 1,
"Name": "СДР (специальные права заимствования)",
"Value": 127.9724,
"Previous": 130.4436
},
"SGD": {
"ID": "R01625",
"NumCode": "702",
"CharCode": "SGD",
"Nominal": 1,
"Name": "Сингапурский доллар",
"Value": 67.764,
"Previous": 68.8743
},
"TJS": {
"ID": "R01670",
"NumCode": "972",
"CharCode": "TJS",
"Nominal": 10,
"Name": "Таджикских сомони",
"Value": 81.2988,
"Previous": 82.8688
},
"TRY": {
"ID": "R01700J",
"NumCode": "949",
"CharCode": "TRY",
"Nominal": 10,
"Name": "Турецких лир",
"Value": 66.1464,
"Previous": 67.7806
},
"TMT": {
"ID": "R01710A",
"NumCode": "934",
"CharCode": "TMT",
"Nominal": 1,
"Name": "Новый туркменский манат",
"Value": 26.2506,
"Previous": 26.7694
},
"UZS": {
"ID": "R01717",
"NumCode": "860",
"CharCode": "UZS",
"Nominal": 10000,
"Name": "Узбекских сумов",
"Value": 84.384,
"Previous": 86.3067
},
"UAH": {
"ID": "R01720",
"NumCode": "980",
"CharCode": "UAH",
"Nominal": 10,
"Name": "Украинских гривен",
"Value": 30.4044,
"Previous": 31.0053
},
"CZK": {
"ID": "R01760",
"NumCode": "203",
"CharCode": "CZK",
"Nominal": 10,
"Name": "Чешских крон",
"Value": 41.0266,
"Previous": 41.8215
},
"SEK": {
"ID": "R01770",
"NumCode": "752",
"CharCode": "SEK",
"Nominal": 10,
"Name": "Шведских крон",
"Value": 96.7925,
"Previous": 98.1669
},
"CHF": {
"ID": "R01775",
"NumCode": "756",
"CharCode": "CHF",
"Nominal": 1,
"Name": "Швейцарский франк",
"Value": 100.2028,
"Previous": 101.0683
},
"ZAR": {
"ID": "R01810",
"NumCode": "710",
"CharCode": "ZAR",
"Nominal": 10,
"Name": "Южноафриканских рэндов",
"Value": 59.9571,
"Previous": 60.8375
},
"KRW": {
"ID": "R01815",
"NumCode": "410",
"CharCode": "KRW",
"Nominal": 1000,
"Name": "Вон Республики Корея",
"Value": 76.5619,
"Previous": 77.7626
},
"JPY": {
"ID": "R01820",
"NumCode": "392",
"CharCode": "JPY",
"Nominal": 100,
"Name": "Японских иен",
"Value": 79.7962,
"Previous": 80.9718
}
}
}
I cant generate a true code for showing all the element in recyclerView...or i can only show 1 element when i use this code on RecyclerAdapter - holder.tvValueName.text = currentItem.AMD.Name
but when i want add all elements whit this code - holder.tvValueName.text = currentItem.currencyModel.Name
- it didnt work...
I already tried change the types of some classes like a val valute: Valute -to- val valute:List<Valute> or val currencyModel: CurrencyModel -to- val currencyModel: List<CurrencyModel>
and then get values with method holder.tvValueName.text = currentItem.currencyModel.get(position).Name
- but i get error with ARRAY...
If anyone has any ideas please help, thanks in advance
interface ApiInterface {
@GET("daily_json.js")
fun getValuteData() : Call<Main>
companion object {
var BASE_URL = "https://www.cbr-xml-daily.ru/"
fun create() : ApiInterface {
val retrofit = Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
.build()
return retrofit.create(ApiInterface::class.java)
}
}
}
class RecyclerAdapter(val context: Context) : RecyclerView.Adapter<RecyclerAdapter.MyViewHolder>() {
var valuteItemList : MutableList<Valute> = mutableListOf()
private var changedData: MutableList<Valute> = mutableListOf()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_adapter,parent,false)
return MyViewHolder(view)
}
override fun getItemCount(): Int {
return changedData.size
}
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
val currentItem = changedData[position]
holder.tvValueName.text = currentItem.AMD.Name
holder.tvValueName.text = currentItem.currencyModel.Name
}
@SuppressLint("NotifyDataSetChanged")
fun setValuteListItems(valuteList: MutableList<Valute>){
valuteItemList.clear()
valuteItemList.addAll(valuteList)
changedData.addAll(valuteItemList)
notifyDataSetChanged()
}
class MyViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {
val tvValueName: TextView = itemView!!.findViewById(R.id.title)
val tvValuteValue: TextView = itemView!!.findViewById(R.id.valute_value)
val tvValuteCharCode: TextView = itemView!!.findViewById(R.id.chare_code)
val image: ImageView = itemView!!.findViewById(R.id.image)
}
}
class MainActivity : AppCompatActivity() {
lateinit var recyclerView: RecyclerView
lateinit var recyclerAdapter: RecyclerAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
recyclerView = findViewById(R.id.recyclerview)
recyclerAdapter = RecyclerAdapter(this)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = recyclerAdapter
val apiInterface = ApiInterface.create().getValuteData()
apiInterface.enqueue( object : Callback<Main> {
override fun onResponse(call: Call<Main>?, response: Response<Main>?) {
Log.d("MyTag","Success ")
if(response!!.body() != null)
//recyclerAdapter.setValuteListItems(response.body()!!.Valute as MutableList<Valute>)
recyclerAdapter.setValuteListItems(mutableListOf(response.body()!!.Valute))
Log.d("MyTag","Success "+response.body().toString())
}
override fun onFailure(call: Call<Main>?, t: Throwable?) {
Log.d("MyTag", "Failure "+t.toString())
}
})
}
}
Whole JSON Model
data class Main(
val Date: String,
val PreviousDate: String,
val PreviousURL: String,
val Timestamp: String,
val Valute: Valute
)
data class CurrencyModel(
val CharCode: String,
val ID: String,
val Name: String,
val Nominal: Int,
val NumCode: String,
val Previous: Double,
val Value: Double
)
data class Valute(
val currencyModel: CurrencyModel,
val AMD: CurrencyModel,
val AUD: CurrencyModel,
val AZN: CurrencyModel,
val BGN: CurrencyModel,
val BRL: CurrencyModel,
val BYN: CurrencyModel,
val CAD: CurrencyModel,
val CHF: CurrencyModel,
val CNY: CurrencyModel,
val CZK: CurrencyModel,
val DKK: CurrencyModel,
val EUR: CurrencyModel,
val GBP: CurrencyModel,
val HKD: CurrencyModel,
val HUF: CurrencyModel,
val INR: CurrencyModel,
val JPY: CurrencyModel,
val KGS: CurrencyModel,
val KRW: CurrencyModel,
val KZT: CurrencyModel,
val MDL: CurrencyModel,
val NOK: CurrencyModel,
val PLN: CurrencyModel,
val RON: CurrencyModel,
val SEK: CurrencyModel,
val SGD: CurrencyModel,
val TJS: CurrencyModel,
val TMT: CurrencyModel,
val TRY: CurrencyModel,
val UAH: CurrencyModel,
val USD: CurrencyModel,
val UZS: CurrencyModel,
val XDR: CurrencyModel,
val ZAR: CurrencyModel
)
JSON
{
"Date": "2022-03-02T11:30:00+03:00",
"PreviousDate": "2022-03-01T11:30:00+03:00",
"PreviousURL": "\/\/www.cbr-xml-daily.ru\/archive\/2022\/03\/01\/daily_json.js",
"Timestamp": "2022-03-01T18:00:00+03:00",
"Valute": {
"AUD": {
"ID": "R01010",
"NumCode": "036",
"CharCode": "AUD",
"Nominal": 1,
"Name": "Австралийский доллар",
"Value": 66.7817,
"Previous": 67.3624
},
"AZN": {
"ID": "R01020A",
"NumCode": "944",
"CharCode": "AZN",
"Nominal": 1,
"Name": "Азербайджанский манат",
"Value": 53.9998,
"Previous": 55.067
},
"GBP": {
"ID": "R01035",
"NumCode": "826",
"CharCode": "GBP",
"Nominal": 1,
"Name": "Фунт стерлингов Соединенного королевства",
"Value": 123.1411,
"Previous": 125.0415
},
"AMD": {
"ID": "R01060",
"NumCode": "051",
"CharCode": "AMD",
"Nominal": 100,
"Name": "Армянских драмов",
"Value": 18.8196,
"Previous": 19.524
},
"BYN": {
"ID": "R01090B",
"NumCode": "933",
"CharCode": "BYN",
"Nominal": 1,
"Name": "Белорусский рубль",
"Value": 29.4765,
"Previous": 33.9264
},
"BGN": {
"ID": "R01100",
"NumCode": "975",
"CharCode": "BGN",
"Nominal": 1,
"Name": "Болгарский лев",
"Value": 52.5944,
"Previous": 53.4592
},
"BRL": {
"ID": "R01115",
"NumCode": "986",
"CharCode": "BRL",
"Nominal": 1,
"Name": "Бразильский реал",
"Value": 17.7795,
"Previous": 18.1182
},
"HUF": {
"ID": "R01135",
"NumCode": "348",
"CharCode": "HUF",
"Nominal": 100,
"Name": "Венгерских форинтов",
"Value": 27.7437,
"Previous": 28.0932
},
"HKD": {
"ID": "R01200",
"NumCode": "344",
"CharCode": "HKD",
"Nominal": 1,
"Name": "Гонконгский доллар",
"Value": 11.7413,
"Previous": 11.9737
},
"DKK": {
"ID": "R01215",
"NumCode": "208",
"CharCode": "DKK",
"Nominal": 1,
"Name": "Датская крона",
"Value": 13.8309,
"Previous": 14.0504
},
"USD": {
"ID": "R01235",
"NumCode": "840",
"CharCode": "USD",
"Nominal": 1,
"Name": "Доллар США",
"Value": 91.7457,
"Previous": 93.5589
},
"EUR": {
"ID": "R01239",
"NumCode": "978",
"CharCode": "EUR",
"Nominal": 1,
"Name": "Евро",
"Value": 102.9112,
"Previous": 104.4772
},
"INR": {
"ID": "R01270",
"NumCode": "356",
"CharCode": "INR",
"Nominal": 10,
"Name": "Индийских рупий",
"Value": 12.1817,
"Previous": 12.3927
},
"KZT": {
"ID": "R01335",
"NumCode": "398",
"CharCode": "KZT",
"Nominal": 100,
"Name": "Казахстанских тенге",
"Value": 18.6621,
"Previous": 18.8393
},
"CAD": {
"ID": "R01350",
"NumCode": "124",
"CharCode": "CAD",
"Nominal": 1,
"Name": "Канадский доллар",
"Value": 72.4346,
"Previous": 73.2646
},
"KGS": {
"ID": "R01370",
"NumCode": "417",
"CharCode": "KGS",
"Nominal": 10,
"Name": "Киргизских сомов",
"Value": 10.7936,
"Previous": 11.0069
},
"CNY": {
"ID": "R01375",
"NumCode": "156",
"CharCode": "CNY",
"Nominal": 1,
"Name": "Китайский юань",
"Value": 14.534,
"Previous": 14.8243
},
"MDL": {
"ID": "R01500",
"NumCode": "498",
"CharCode": "MDL",
"Nominal": 10,
"Name": "Молдавских леев",
"Value": 49.8618,
"Previous": 50.8472
},
"NOK": {
"ID": "R01535",
"NumCode": "578",
"CharCode": "NOK",
"Nominal": 1,
"Name": "Норвежская крона",
"Value": 10.4292,
"Previous": 10.4927
},
"PLN": {
"ID": "R01565",
"NumCode": "985",
"CharCode": "PLN",
"Nominal": 1,
"Name": "Польский злотый",
"Value": 21.9288,
"Previous": 22.2151
},
"RON": {
"ID": "R01585F",
"NumCode": "946",
"CharCode": "RON",
"Nominal": 1,
"Name": "Румынский лей",
"Value": 20.7899,
"Previous": 21.1342
},
"XDR": {
"ID": "R01589",
"NumCode": "960",
"CharCode": "XDR",
"Nominal": 1,
"Name": "СДР (специальные права заимствования)",
"Value": 127.9724,
"Previous": 130.4436
},
"SGD": {
"ID": "R01625",
"NumCode": "702",
"CharCode": "SGD",
"Nominal": 1,
"Name": "Сингапурский доллар",
"Value": 67.764,
"Previous": 68.8743
},
"TJS": {
"ID": "R01670",
"NumCode": "972",
"CharCode": "TJS",
"Nominal": 10,
"Name": "Таджикских сомони",
"Value": 81.2988,
"Previous": 82.8688
},
"TRY": {
"ID": "R01700J",
"NumCode": "949",
"CharCode": "TRY",
"Nominal": 10,
"Name": "Турецких лир",
"Value": 66.1464,
"Previous": 67.7806
},
"TMT": {
"ID": "R01710A",
"NumCode": "934",
"CharCode": "TMT",
"Nominal": 1,
"Name": "Новый туркменский манат",
"Value": 26.2506,
"Previous": 26.7694
},
"UZS": {
"ID": "R01717",
"NumCode": "860",
"CharCode": "UZS",
"Nominal": 10000,
"Name": "Узбекских сумов",
"Value": 84.384,
"Previous": 86.3067
},
"UAH": {
"ID": "R01720",
"NumCode": "980",
"CharCode": "UAH",
"Nominal": 10,
"Name": "Украинских гривен",
"Value": 30.4044,
"Previous": 31.0053
},
"CZK": {
"ID": "R01760",
"NumCode": "203",
"CharCode": "CZK",
"Nominal": 10,
"Name": "Чешских крон",
"Value": 41.0266,
"Previous": 41.8215
},
"SEK": {
"ID": "R01770",
"NumCode": "752",
"CharCode": "SEK",
"Nominal": 10,
"Name": "Шведских крон",
"Value": 96.7925,
"Previous": 98.1669
},
"CHF": {
"ID": "R01775",
"NumCode": "756",
"CharCode": "CHF",
"Nominal": 1,
"Name": "Швейцарский франк",
"Value": 100.2028,
"Previous": 101.0683
},
"ZAR": {
"ID": "R01810",
"NumCode": "710",
"CharCode": "ZAR",
"Nominal": 10,
"Name": "Южноафриканских рэндов",
"Value": 59.9571,
"Previous": 60.8375
},
"KRW": {
"ID": "R01815",
"NumCode": "410",
"CharCode": "KRW",
"Nominal": 1000,
"Name": "Вон Республики Корея",
"Value": 76.5619,
"Previous": 77.7626
},
"JPY": {
"ID": "R01820",
"NumCode": "392",
"CharCode": "JPY",
"Nominal": 100,
"Name": "Японских иен",
"Value": 79.7962,
"Previous": 80.9718
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的模型中,将
val Valute: Valute
更改为
val Valute = ArrayList()
并将响应 json 从
“Valute”更改为:{
“澳元”:{
至
“价值”:[
"AUD": {
通过更改此设置,您可以获得 Arraylist 形式的 Value,然后您可以将数据加载到适配器中
In your model change
val Valute: Valute
to
val Valute = ArrayList()
and change your response json from
"Valute": {
"AUD": {
to
"Valute": [
"AUD": {
By changing this you can get the Valute as Arraylist and then you can load the data in adapter