Android Studio 从带有 sqlite 的数据库到 GridView 和标题列

标签 android sqlite datagridview

我的数据库中有一张表:

piecetable (description, imgdescription, imgpiece,  codsag, codoe, n, csct, a, b, cod_auto, cod_brand)

我有一个简单的 GridView,它有八个固定列,称为 piecedatagridview 我想从数据库中获取数据并放入这个 GridView。
我该怎么做?

两列必须包含从 imgdescription 和 imgpiece 中获取的两张图像,可在 drawable 文件夹中找到。

我如何首先将粗体标题列加载到 GridView 中,然后从数据库中加载行?

代码:

<GridLayout
            android:layout_width="1172dp"
            android:layout_height="290dp"
            android:layout_row="2"
            android:layout_column="0">

            <GridView
                android:layout_width="wrap_content"
                android:layout_height="263dp"
                android:id="@+id/tabellaPezzi"
                android:layout_row="0"
                android:layout_column="0"
                android:numColumns="8"
                android:smoothScrollbar="false" />

        </GridLayout>

最佳答案

我将用另一个问题来回答您的问题:您需要 GridList 有什么用?当将相同的元素类型表示为类似网格的布局时,使用 GridList;在你的情况下,一个 ListView 包装了你需要显示的所有项目似乎是更好的选择。 对于 drawables 部分,将 res/drawable 文件夹的资源 int 地址(即 R.drawable.drawable_name)保存到您的数据库中,然后在构建行时获取实际图像。

关于Android Studio 从带有 sqlite 的数据库到 GridView 和标题列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31870112/

相关文章:

android - 如何在android中压缩视频文件

android - 从 SQlite 检索的数据如何在 android 中存储为 'list of favorites'?

c# - 列中的按钮,获取它来自 Click 事件处理程序的行

c# - 在数据库中插入 datagridview 的值

c# - 如何获取 Datagridview Combobox 所选项目的文本?

java - 将 DataSnapshot 转换为类对象

android - 如何使用 QAndroidJniObject 从 Qt 内部调用 Java 代码?

android - 将 set<String> 数据类型转换为 android 中的 String 数据类型

sql JOIN 与 WHERE 上的 bool 值

c# - 对于某些客户,无法加载 DLL 'System.Data.SQLite.dll' : The specified module could not be found.(HRESULT 异常:0x8007007E)