i have json as bellow :
{
"transaksi": {
"jenis_link": "unit_link",
"rks_ulink": [
{
"lji_invest": "Excellink Dynamic Fund",
"tgl": "22/05/2013",
"harga_unit": "3,581.38",
"nilai": "0.000",
"total_unit": "0.0000"
},
{
"lji_invest": "Excellink Aggressive Fund",
"tgl": "22/05/2013",
"harga_unit": "3,758.73",
"nilai": "35,737,078.757",
"total_unit": "9,507.7435"
}
],
"ulink": [
{
"jumlah_unit": 46.9545,
"investasi": "Excellink Aggressive Fund",
"harga_unit": 2041.807,
"tgl_nab": "25/07/2007",
"transaksi": "Alokasi Investasi",
"jumlah": 95872
},
{
"jumlah_unit": 54.722,
"investasi": "Excellink Aggressive Fund",
"harga_unit": 1827.417,
"tgl_nab": "27/08/2007",
"transaksi": "Alokasi Investasi",
"jumlah": 100000
},
{
"jumlah_unit": -2.2826,
"investasi": "Excellink Aggressive Fund",
"harga_unit": 1857.119,
"tgl_nab": "17/09/2007",
"transaksi": "Penarikan-Potongan Aug 07",
"jumlah": 4239
},
{
"jumlah_unit": 186.3333,
"investasi": "Excellink Dynamic Fund",
"harga_unit": 2146.691,
"tgl_nab": "25/10/2007",
"transaksi": "Alokasi Investasi",
"jumlah": 400000
},
{
"jumlah_unit": -7.5143,
"investasi": "Excellink Dynamic Fund",
"harga_unit": 2185.977,
"tgl_nab": "01/11/2007",
"transaksi": "Penarikan-Potongan Oct 07",
"jumlah": 16426
},
{
"jumlah_unit": 186.2001,
"investasi": "Excellink Dynamic Fund",
"harga_unit": 2148.226,
"tgl_nab": "26/11/2007",
"transaksi": "Alokasi Investasi",
"jumlah": 400000
},
{
"jumlah_unit": -7.5314,
"investasi": "Excellink Dynamic Fund",
"harga_unit": 2183.127,
"tgl_nab": "03/12/2007",
"transaksi": "Penarikan-Potongan Nov 07",
"jumlah": 16442
},
{
"jumlah_unit": 183.0457,
"investasi": "Excellink Dynamic Fund",
"harga_unit": 2185.247,
"tgl_nab": "26/12/2007",
"transaksi": "Alokasi Investasi",
"jumlah": 400000
} ]
}
}
as you see, few json "investasi"
values are same with "Excellink Dynamic Fund"
and others with "Excellink Aggressive Fund"
. i want to collect it base one json json "investasi"
with same values, but my problems are i don't know how to collect it in one view and others in others view. for detail i enclosure two image :
json "investasi"
values are same with "Excellink Dynamic Fund"
under this view is json "investasi"
values are same with "Excellink Aggressive Fund"
so far i have make two layout, first layout is containing listview :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/medium_gray">
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#FF0000"
android:text="TRANSAKSI"
android:textStyle="bold"
android:divider="#000000"
android:dividerHeight="1dp"
android:layout_marginTop="8dp"/>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/size10ptWhite3dpBold"
android:layout_width="0dip"
android:layout_weight=".35"
android:gravity="left"
android:orientation="vertical"
android:paddingTop="5dip"
android:paddingBottom="10dip">
<!--Kolom 1-->
<TextView
android:text="Transaksi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="17sp"
android:paddingTop="10dip"
android:paddingBottom="10dip" />
</LinearLayout>
<!-- Kolom 2 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/size10ptWhite3dpBold"
android:layout_width="0dip"
android:layout_weight=".35"
android:orientation="vertical"
android:paddingTop="5dip"
android:paddingBottom="10dip" >
<TextView
android:text="Jumlah"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:gravity="center" />
<TextView
android:text="Tanggal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#b5b5b5"
android:textSize="14sp"
android:gravity="center"
android:paddingBottom="10dip"/>
</LinearLayout>
<!-- Kolom 3 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/size10ptWhite3dpBold"
android:layout_width="0dip"
android:layout_weight=".30"
android:orientation="vertical"
android:paddingTop="5dip"
android:paddingBottom="10dip">
<TextView
android:id="@+id/jumlah_unit"
android:text="Jumlah Unit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:gravity="right"/>
<TextView
android:id="@+id/harga_unit"
android:text="Harga Unit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#b5b5b5"
android:gravity="right"
android:paddingBottom="10dip"/>
</LinearLayout>
</TableRow>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<include layout="@layout/line"/>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#000000"
android:dividerHeight="1dp"
android:focusable="false"
android:clickable="false"/>
</LinearLayout>
second layout for value json :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@color/medium_gray">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/size10ptWhite3dpBold"
android:layout_width="0dip"
android:layout_weight=".33"
android:gravity="left"
android:orientation="vertical"
android:paddingTop="5dip"
android:paddingBottom="10dip">
<!--Kolom 1-->
<TextView
android:id="@+id/transaksi"
android:text="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="17sp"
android:paddingTop="10dip"
android:paddingBottom="10dip" />
</LinearLayout>
<!-- Kolom 2 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/size10ptWhite3dpBold"
android:layout_width="0dip"
android:layout_weight=".33"
android:orientation="vertical"
android:paddingTop="5dip"
android:paddingBottom="10dip" >
<TextView
android:id="@+id/jumlah"
android:text="Jumlah"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:gravity="center" />
<TextView
android:id="@+id/tanggal"
android:text="Tanggal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#b5b5b5"
android:textSize="14sp"
android:gravity="center"
android:paddingBottom="10dip"/>
</LinearLayout>
<!-- Kolom 3 -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/size10ptWhite3dpBold"
android:layout_width="0dip"
android:layout_weight=".33"
android:orientation="vertical"
android:paddingTop="5dip"
android:paddingBottom="10dip">
<TextView
android:id="@+id/jumlah_unit"
android:text="Jumlah Unit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:paddingTop="10dip"
android:paddingBottom="10dip"
android:gravity="right"/>
<TextView
android:id="@+id/harga_unit"
android:text="Harga_Unit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#b5b5b5"
android:gravity="right"
android:paddingBottom="10dip"/>
</LinearLayout>
</LinearLayout>
this is how i parse my json :
JSONObject jsonObject = new JSONObject(result);
JSONObject transaksi = jsonObject.getJSONObject("transaksi");
for (int i=0; i<transaksi.length();i++){
String jenis_link = transaksi.getString("jenis_link");
RingkasanUlinkVariabel VarRKS = null;
JSONArray rks_ulink = transaksi.getJSONArray("rks_ulink");
for (int j=0; j<rks_ulink.length();j++){
JSONObject rks = rks_ulink.getJSONObject(j);
VarRKS= new RingkasanUlinkVariabel(rks.optString("lji_invest"),
rks.optString("total_unit"),
rks.optString("harga_unit"),
rks.optString("nilai"),
rks.optString("tgl"));
ListRingkasan.add(VarRKS);
System.out.println("Adam levine");
}
UnitLinkVariabel VarUnit = null;
JSONArray ulink = transaksi.getJSONArray("ulink");
for (int k=0; k<ulink.length();k++){
JSONObject unit = ulink.getJSONObject(k);
VarUnit= new UnitLinkVariabel(unit.optString("investasi"),
unit.optString("transaksi"),
unit.optString("jumlah"),
unit.optString("tgl_nab"),
unit.optString("jumlah_unit"),
unit.optString("harga_unit"));
ListUnitLink.add(VarUnit);
so how to collect json with same value in one view and others in another view and make a dynamic view in one layout? i hope somebody can help me to solve my problem