【问题标题】:how to add several images in a listview after getting their names from the sqlite database从 sqlite 数据库中获取名称后如何在列表视图中添加多个图像
【发布时间】:2014-06-14 13:09:36
【问题描述】:

我有一个使用 sqlite 的 android 应用程序,在它获取数据后,它必须显示在列表视图中。

我的问题是如何显示图像?

谁能帮帮我???

这是我的代码

//但是这里显示的是同一个大厅列表的图像如何在正确的位置显示每个图像??

for (int i = 0; i < 49; i++) {


            ImageView imagenow = (ImageView) convertView
                    .findViewById(R.id.imageView1);
            // flag1
            int imageid = context.getResources().getIdentifier("brazil_flag",
                    "drawable", context.getPackageName());

            imagenow.setImageResource(imageid);
        }

【问题讨论】:

标签: android android-listview imageview android-sqlite baseadapter


【解决方案1】:

从 MVC 的角度思考会有所帮助 MVC pattern in Android?

  1. 使用 ListView 创建一个布局,其中包含每个元素中的图像
  2. 创建适配器以从数据库中读取图像
  3. 在Activity中,使用Adapter填充ListView中的Images

【讨论】:

    猜你喜欢
    • 2014-06-13
    • 2014-04-01
    • 2017-04-30
    • 2015-06-05
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多