以下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