我如何get and show
每JSON's Object's value
那些我有一個名爲Array
內learning
For循環遍歷JSON對象的數組內
這裏是JSON
陣列的樣子:
"learning": [
{
"code":"2K14 - 2",
"os":"Windows - 2"
},
{
"code":"2K15 - 2",
"os":"Linux - 2"
},
{
"code":"2K16 - 2",
"os":"Mac - 2"
}
]
代碼
List<Learning> learning = value.getLearning();
for(Learning m : learning) {
// I guess, here I am missing something, which is really useful
String code = m.getCode();
String os = m.getOs();
viewHolder.learning.setText("Code: "+code+" OS: "+os);
}
當I execute
我的程序,getting
此:
Code: 2k16, OS: Mac - 2
而我want to get
像this
:
Code: 2k14 OS: Windows - 2, Code: 2k15 OS: Linux - 2, Code: 2k16 OS: Mac - 2
你是如何解析JSON? – Blackbelt
'viewholder',我假設你在列表適配器中使用了Viewholder模式。無需循環。 GetView運行多次來呈現列表項。 它應該根據位置顯示一個項目。 調查getItem(position)'。 – TheSunny
使用Retrofit @Blackbelt – Oreo