回答
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>
我的對象是List中的每個類別。那麼爲什麼我需要使用兩個listview和textview?你能否請編輯答案 – CarinaMj
看看這個例子希望能對你有所幫助 –
正如我所看到的,由上述中的行是大小不一樣。如果您的計劃是要建立列表項目,但可能自己創建它,但也許這將是一個相對較大的任務(「重新發明方向盤」,如果您知道我的意思)。在這裏,你可以找到當你有ListView
或TableLayout
之間做出選擇,你應該考慮什麼,這可能是另一種解決方案SO話題:
在我的愚見:因爲我們可以在圖像上看到是表和不是一個表,它應該用TableLayout來做。
如果這是你的意見也是如此,這裏是官方教程指南TableLayout ...;)
https://developer.android.com/guide/topics/ui/layout/grid.html
- 1. 是否有任何理由來定義自定義代表?
- 2. Java:是否有可能制定一套方法或任何類似的工作?
- 3. Typo3:是否有可能爲擴展製作自定義柔性?
- 4. c#將方法中的變量定義爲列表 - 是否有可能?
- 5. 是否有任何可能的方法來匹配第n個字符?
- 6. 是否有任何方法使用列表中的數字來執行操作?
- 7. 速度:是否有任何方法來檢查是否定義變量
- 8. 是否有可能在Recyclerview中製作自定義佈局,看起來像這樣?
- 9. 是否有任何可行的方法來連接java與c + +
- 10. 是否有任何可能的方法來禁用Joomla的swMenu中的HOVER?
- 11. 是否有可能重寫這個棘手的擴展方法?
- 12. 是否有可能爲resharper定義自定義命名約定?
- 13. 是否有可能有一個自定義.gitignore?只讀訪問?
- 14. 是否可以使用Monotouch.Dialog創建一個像這樣的自定義列表?
- 15. 是否有任何可能的方法來使驗證碼解算器?
- 16. 是否有任何方法來分隔AS3中的類定義和聲明
- 17. 是否有任何選項可以自定義stroke_bounds? (Rails Prawn)
- 18. 是否有任何製作本地'defonce'的方法? (Clojure)
- 19. 是否有可能使postgres自動更新聽覺表的列定義?
- 20. 是否有簡明的方法來確定列表中的任何對象是否爲真?
- 21. 是否可以製作可自定義的WPF樣式?
- 22. 是否有可能從Clojure重新定義Java方法?
- 23. 是否有任何方法來ALTER列以關閉'NOT NULL'?
- 24. 是否有任何算法來判斷一個字符串是否有意義
- 25. 是否有任何方法來檢查行中是否存在多列的值
- 26. 是否有可能這兩個功能
- 27. 是否可以製作一個沒有任何活動的apk?
- 28. 是否有可能有一個雷神方法是不明確的任務
- 29. 有沒有更好的方法來搜索這個列表中的任意值?
- 30. 是否有可能在nodejs中創建自定義http請求方法
要麼是另一個小部件,或者通過使用有幾個定製單元模擬表'列'和可能行。 –
您可以使用TableLayout而不是自定義的listview。 –