2017-05-15 15 views
0

SimpleCursorAdapterを使用してデータベースにListViewを設定しました。 私はListViewに2行、日付のために1つ(私のテーブルの1つの列)と私のデータベースの2つの列のためのもう1つの列があります。サブアイテムを含むListViewは2回同じ情報を避ける

第1列は日付、第2はレッスン、第3はレッスンのテーマです。

問題がある:私は同じ日1回のレッスン以上のものを持っている場合、それは私のアプリでは以下のように表示されます:

15.05.17

英語読解

15.05.17

英語聞き取り

しかし、私は同じ日に複数のレッスンがあれば、最初の行を1回だけ表示したいと思いますトップ)、このような:

15.05.17

英語読解

英語

リスニングどのように私はそれを行うことができますか?

はここに私のlist_row_page_itude.xml私は私のコードでそれを実装する方法

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:padding="16dp"> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/linearLayout" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/text_date" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Date"/> 

</LinearLayout> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/linearLayout" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginTop="11dp"> 

    <TextView 
     android:id="@+id/text_branche_cours" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="English"/> 

    <TextView 
     android:id="@+id/text_trait" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text=" - " /> 
    <TextView 
     android:id="@+id/text_designation" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Reading" 
     /> 
</LinearLayout> 
です:

lvJalons = (ListView)findViewById(R.id.ListJalons); 
    Cursor cursor = dbhelper.getAllJalons(); 
    String[] from = { "date_point", "designation_jalon","description_jalon" }; 
    int[] to = {R.id.text_date,R.id.text_branche_cours, R.id.text_designation }; 
    adapter = new SimpleCursorAdapter(this, R.layout.list_row_page_itude, cursor, from, to, 0); 
    lvJalons.setAdapter(adapter); 
    adapter.notifyDataSetChanged(); 

そして、私が使用して私のデシベルの方法(getAllJalons()):

` public Cursor getAllJalons() 
{ 
    Calendar c = Calendar.getInstance(); 
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); 
    Date date = c.getTime(); 
    String currentDate = df.format(date); 

    String query = ("select ID as _id,date_jalon,date_point,devoir,evaluation,importance,designation_jalon, description_jalon,cours_fk from "+TABLE_JALONS+" where date(date_jalon) >='"+currentDate+"'"); 
    Open(); 
    Cursor cursor = db.rawQuery(query,null); 
    return cursor; 
}` 

ありがとう。

答えて

0

CursorAdapterは直接セクショニングをサポートしていません。あなたは、この機能をCursorAdaptersにまで拡張したこのプロジェクトを見ることができます。 - https://github.com/twotoasters/SectionCursorAdapter

+0

私はあなたのリンクを見ましたが、私の問題の例はありませんか? – Dom

+0

その例はそのリンクにあります。 – Anoop

関連する問題