2017-04-06 7 views
-3

下の画像のようにアンドロイドカスタムリストビューを実行する方法はありますか? カスタムアダプターには、以下のような別のリストビューが必要です。 enter image description hereこのカスタムリストを作成する方法はありますか?

ありがとうございます。私が見ることができるように

+0

またはそれにはいくつか持っているカスタムセルを使用してテーブルをシミュレート列とおそらくは行。 –

+0

カスタムリストビューの代わりにTableLayoutを使用できます。 –

答えて

0

activity_main.xml

<LinearLayout 
    android:id = "@+id/relativeLayout1" 
    android:layout_width = "fill_parent" 
    android:layout_height = "wrap_content" > 

    <TextView 
     android:layout_width = "0dp" 
     android:layout_height = "wrap_content" 
     android:layout_weight = "2" 
     android:gravity = "center" 
     android:padding = "5dp" 
     android:text = "Firt column title" 
     android:textColor = "#ffffff"/ > 

    <TextView 
     android:layout_width = "0dp" 
     android:layout_height = "wrap_content" 
     android:layout_weight = "1.5" 
     android:gravity = "center" 
     android:padding = "5dp" 
     android:text = "Second column title" 
     android:textColor = "#ffffff" /> 

    <TextView 
     android:layout_width = "0dp" 
     android:layout_height = "wrap_content" 
     android:layout_weight = "1" 
     android:gravity = "center" 
     android:padding = "5dp" 
     android:text = "third column title" 
     android:textColor = "#ffffff" /> 
</LinearLayout> 

<ListView 
    android:id = "@+id/listview" 
    android:layout_width = "match_parent" 
    android:layout_height = "wrap_content" 
    android:divider = "@null"/> 

cell_shape.xml

<layer-list xmlns:android = "http://schemas.android.com/apk/res/android"> 

<item 
    android:left = "-2dp" 
    android:top = "-2dp"> 
    <shape android:shape = "rectangle" > 
     <solid android:color = "@android:color/transparent" /> 

     <stroke 
      android:width = "1dp" 
      android:color = "@color/colorCell" /> 
    </shape> 
</item> 

listview_row.xml

<LinearLayout 
    android:id = "@+id/relativeLayout1" 
    android:layout_width = "fill_parent" 
    android:layout_height = "wrap_content" 
    android:background = "@color/colorCell" > 

    <TextView  
     android:id = "@+id/sNo"  
     android:layout_width = "0dp" 
     android:layout_height = "match_parent" 
     android:layout_weight = "1" 
     android:background = "@drawable/cell_shape" 
     android:ellipsize = "end" 
     android:padding = "5dp" 
     android:text = "categorie" 
     android:singleLine = "true" /> 

<ListView 
    android:id = "@+id/listview_first section list" 
    android:layout_width = "match_parent" 
    android:layout_height = "wrap_content" 
    android:divider = "@null"/> 
<ListView 
    android:id = "@+id/listview_number_section_list" 
    android:layout_width = "match_parent" 
    android:layout_height = "wrap_content" 
    android:divider = "@null"/> 


</LinearLayout> 
+0

私のオブジェクトはリストを持つすべてのカテゴリです。なぜ2つのリストビューとテキストビューを使用する必要がありますか?あなたは答えを編集してください – CarinaMj

+0

この例を見て、あなたが助けてくれることを願ってください –

0

、上記説明の行があります同じ大きさではない。あなたの計画がdinamicallyリストアイテムを構築する場合は、それ自体を作成することは可能ですが、おそらくそれは比較的大きな仕事(あなたが私が意味することを知っている場合は、 "ホイールを再発明する")でしょう。私たちはあなたのイメージに見ることができるものので:私の謙虚な意見では

ListView or TableLayout?

:ここではあなたがListViewTableLayoutの間で選択しなければならないとき、あなたは別の解決策になることができ、考慮しなければならないかについてのSOトピックを見つけることができますテーブルであり、ではないのリストは、TableLayoutで作成する必要があります。

それはあなたの意見があまりにも、ここでTableLayoutの公式チュートリアルガイド...である場合; '別のウィジェットのいずれかである)

https://developer.android.com/guide/topics/ui/layout/grid.html

関連する問題