java 在android中创建数据表的最佳方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31844919/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 19:14:09  来源:igfitidea点击:

What is the best way to create a data table in android?

javaandroidmaterial-designandroid-tablelayout

提问by Arsen Gyulgazyan

I would like to create a table which is filled by data from DB. I know that it ispossible to create a dynamic table using TableLayoutbut I'm not sure that it's the best solution im my case.
Here is an example of what I want to create(the first table on the page).

我想创建一个由 DB 中的数据填充的表。我知道这可以创建使用动态表TableLayout,但我不知道这是最好的解决办法即时通讯我的情况。
这是我想要创建的示例(页面上的第一个表格)。

回答by androholic

I'll give you my inputs on this.

我会给你我的意见。

If your data is limited and you are sure to display all of it in a single screen in a presentable manner, then yes, a TableLayout will suffice.

如果您的数据有限,并且您确保以可呈现的方式在单个屏幕中显示所有数据,那么是的,TableLayout 就足够了。

However, in a real world, flexibility counts so you should always consider the possibility that your data may expand in the future. Keeping that in mind, you should use a ListView or a RecyclerView in this case. Define a base layout for each row of your list or recycler view and then connect the data from your database to this view using a suitable adapter.

但是,在现实世界中,灵活性很重要,因此您应该始终考虑您的数据将来可能会扩展的可能性。请记住,在这种情况下,您应该使用 ListView 或 RecyclerView。为列表或回收站视图的每一行定义基本布局,然后使用合适的适配器将数据库中的数据连接到此视图。

For starters: https://developer.android.com/training/material/lists-cards.html

对于初学者:https: //developer.android.com/training/material/lists-cards.html