Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android:如何将JSON分为两部分_Java_Android_Json_Android Layout - Fatal编程技术网

Java Android:如何将JSON分为两部分

Java Android:如何将JSON分为两部分,java,android,json,android-layout,Java,Android,Json,Android Layout,我的建议如下: { "pp": { "status_marital_pmg": "BELUM MENIKAH", "nama_pmg": "tomy", "kerjab_pmg": "-", "pendidikan_pmg": "S1", "agama_pmg": "KRISTENKATOLIK", "bidang_industri_pmg": "JASAKEUANGAN",

我的建议如下:

    {
    "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));
            }
试试看{
JSONObject JSONObject=新JSONObject(结果);
PPVariabel varpp=null;
PPPelengkapvariabel varppl=null;
JSONObject pp=JSONObject.getJSONObject(“pp”);
{

对于(int i=0;ii)如果要将JSON分成两部分,则需要为JSON响应添加两个单独的数组,其中一个数组包含ListPP的详细信息,另一个数组包含PP arraylist中的ListPPL。
 <?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>