以下this SO解決方案,我已經成功parsed JSON
,但不知道如何同時顯示headings
和TextViews points
。我如何顯示多個標題和點單活動
這是我JSON
的樣子:
{
"technology": [
{
"title": "Android",
"description": [
{
"heading": "Manufactures",
"points": [
"Google",
"Samsung"
]
},
{
"heading": "Platforms",
"points": [
"Kitkat",
"ICS"
]
}
]
}
]
}
舉個例子,如果我這樣做tap on Android
,然後我want to show
是這樣的:
Manufactures
[dot] Google
[dot] Samsung
Platforms
[dot] Kitkat
[dot] ICS
對於reference
看到這個圖片:
代替Why We Like It
,我想顯示Manufactures
並且代替Need to Know
,我想顯示Platforms
(以及它們各自的點),如圖所示。
但getting
像this
:
Platforms
[dot] ICS
對於reference
看到這個圖片:
那麼是什麼原因?以及我必須在我的代碼中進行更改?
DescriptionActivity.java:-
for(int s=0; s<arrayListDescription.size(); s++)
{
description = arrayListDescription.get(s);
strHeading = " " + description.getHeading();
Log.d("heading::", strHeading);
arrayListPoints = description.getPoints();
for(int z=0; z<arrayListPoints.size(); z++)
{
String dot = getString(R.string.dot);
strPoints = "";
strPoints += " " + dot + " " + arrayListPoints.get(z) + "\n";
Log.d("points::", strPoints);
}
textViewPoints.setText(Html.fromHtml(strPoints));
}
textViewHeading.setText(Html.fromHtml(strHeading));
textViewHeading.setTextSize(20);
}
activity_description.xml: -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/textPoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
這就是我的Log
說:
08-28 04:47:39.653: D/heading::(1902): Manufactures
08-28 04:47:39.653: D/points::(1902):  ·Google
08-28 04:47:39.671: D/points::(1902):  ·Samsung
08-28 04:47:39.761: D/heading::(1902): Platforms
08-28 04:47:39.761: D/points::(1902):  ·Kitkat
08-28 04:47:39.761: D/points::(1902):  ·ICS
通過using
@ Dreagen的解決方案,getting
像this
:
Platforms
null[dot]Google[dot]Samsung[dot]Kitkat[dot]ICS
對於reference
看到這個image
:
我用這個代碼:
for(int z=0; z<arrayListPoints.size(); z++)
{
String dot = getString(R.string.dot);
// strPoints += dot + arrayListPoints.get(z) + "\n";
strPoints += " ·" + arrayListPoints.get(z) + System.getProperty("line.separator");
Log.d("points::", strPoints);
}
非常感謝你@DIVA – Mysterious 2014-08-28 12:17:43
!!!!歡迎! – KOTIOS 2014-08-28 12:19:29
嘿,我需要你的幫助,這很緊急!請儘快來@DIVA – Mysterious 2014-08-29 07:39:05