信息未按我的意愿显示

时间:2013-01-17 01:47:59

标签: android json layout

我正在从json文件中读取数据,它将显示如下信息:

Time|Subject|Lecturer
Monday
09:15|Nature|AL23
Monday
10:15|Nature|AL33
Tuesday
09:15|Maths|AS12
Tuesday
12:15|English|AC23

但我希望显示的信息如

Time|Subject|Lecturer
Monday
09:15|Nature|AL23
10:15|Nature|AL33
Tuesday
09:15|Maths|AS12
12:15|English|AC23

(当天只显示一次)。 我最接近的方式是按照我希望的方式显示信息:

View linearLayout =  findViewById(R.id.info);

    int a = 0;
    //((LinearLayout) linearLayout).addView(valueTV);   
    while(x < 41)
    {
        if(x == 8 || x == 16 || x == 24 || x == 32 || x == 40)
        {

                TextView valueTV = new TextView(this);
                valueTV.setText(fetch2.get(a));
                valueTV.setId(x);
                valueTV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
                a++;

            ((LinearLayout) linearLayout).addView(valueTV); 

            System.out.println(x);
            x++;
        }
        else
        {
            lv = (ListView) findViewById(R.id.listview);
            adapter = new CustomAdapter(MainActivity.this, R.id.listview, fetch);
            lv.setAdapter(adapter);
            x++;
        }
    }

这确实列出了5天但仅在时间,主题和讲师之后,但在时间之前。我有

<TableLayout
    android:id="@+id/info"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</TableLayout>
时间,主题和讲师之间以及列表视图(针对时代,科目和讲师)的布局。我确实尝试将tablelayout放在listview调用布局的同一个xml文件中,但是当我运行它时,我在调试选项卡中得到以下内容,并且应用程序没有运行。

Thread [<1> main] (Suspended (exception RuntimeException))  
    <VM does not provide monitor information>   
    ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1651    
    ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1667 
    ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 117   
    ActivityThread$H.handleMessage(Message) line: 935   
    ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 130 
    ActivityThread.main(String[]) line: 3687    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 507  
    ZygoteInit$MethodAndArgsCaller.run() line: 867  
    ZygoteInit.main(String[]) line: 625 
    NativeStart.main(String[]) line: not available [native method]  
Thread [<8> Binder Thread #2] (Running) 
Thread [<7> Binder Thread #1] (Running) 

我不确定如何按照我的意愿显示信息(即只显示一次的那一天)。

0 个答案:

没有答案