我有json如下:
{
"pp": {
"status_marital_pmg": "BELUM MENIKAH",
"nama_pmg": "tomy",
"kerjab_pmg": "-",
"pendidikan_pmg": "S1",
"agama_pmg": "KRISTENKATOLIK",
"bidang_industri_pmg": "JASAKEUANGAN",
"warga_pmg": "-",
"hubungan_pmg_ttg": "DiriSendiri",
"pendanaana_pmg": "GAJI",
"pendanaan_pmg": "GAJI",
"usia_pmg": 33,
"penghasilan_pmg": "-",
"kelamin_pmg": "Pria",
"tujuan_pmg": "INVESTASI",
"tujuana_pmg": "INVESTASI",
"kerja_pmg": "KARYAWAN",
"bidang_industria_pmg": "JASAKEUANGAN"
}
}
我想把我的json分成两部分,它们是:listPP和listPPL,在我的布局中,我想把它分成两部分,第一部分用于listPP,另一部分用于listPPL,但是当我运行它时,只有一个部分:ListPPL,它显示在布局的第一部分,而不是布局的第二部分。 ListPP没有显示任何内容,这是我的代码:
try {
JSONObject jsonObject = new JSONObject(result);
PPVariabel varpp = null;
PPPelengkapvariabel varppl=null;
JSONObject pp = jsonObject.getJSONObject("pp");
{
for (int i=0; i<PP.length;i++){
varpp= new PPVariabel(pp.optString("nama_pmg"),
pp.optString("kerjab_pmg"),
pp.optString("warga_pmg"),
pp.optString("usia_pmg"),
pp.optString("status_marital_pmg"),
pp.optString("kelamin_pmg"),
pp.optString("agama_pmg"),
pp.optString("pendidikan_pmg"));
listPP.add(varpp);
LinearLayout linear1=(LinearLayout)findViewById(R.id.pp1);
list=(ListView)findViewById(android.R.id.list);
setListAdapter(new PPViewerAdapter(this, listPP,PP));
}
for (int j=0; j<Pelengkap.length;j++){
varppl= new PPPelengkapvariabel (pp.optString("tujuan_pmg"),
pp.optString("tujuana_pmg"),
pp.optString("penghasilan_pmg"),
pp.optString("pendanaan_pmg"),
pp.optString("pendanaana_pmg"),
pp.optString("kerja_pmg"),
pp.optString("bidang_industri_pmg"),
pp.optString("bidang_industria_pmg"),
pp.optString("hubungan_pmg_ttg"));
listPPL.add(varppl);
LinearLayout linear2=(LinearLayout)findViewById(R.id.dpl2);
list=(ListView)findViewById(R.id.ppl);
setListAdapter(new PPDataPelengkapAdapter(this, listPPL,Pelengkap));
}
这是我的布局:
<?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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdge="vertical"
android:fadeScrollbars="true"
android:fadingEdgeLength="1dp"
android:scrollbars="none">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/pp1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#FF0000"
android:text="DATA DIRI"
android:textStyle="bold"
android:divider="#000000"
android:dividerHeight="1dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:typeface="sans"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="470dp"
android:divider="#000000"
android:dividerHeight="1dp"
android:focusable="false"
android:clickable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/dpl2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#FF0000"
android:text="DATA PELENGKAP"
android:textStyle="bold"
android:divider="#000000"
android:dividerHeight="1dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:typeface="sans"/>
<ListView
android:id="@+id/ppl"
android:layout_width="fill_parent"
android:layout_height="1000dp"
android:divider="#000000"
android:dividerHeight="1dp"
android:focusable="false"
android:clickable="false"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
我的代码有什么问题吗?如果有,是否有人可以帮助我解决我的问题?谢谢