java - 将 int[] 更改为 IntArray 导致无法在应用程序中加载图像

标签 java android int

我改变这个int[]

    int[] imageID;
        = {
        R.drawable.farm_small,
        R.drawable.scroll_small,
        R.drawable.desert_small,
        R.drawable.bg_blue_small,
        R.drawable.city_small,
        R.drawable.clip_small,
        R.drawable.grass_small,
        R.drawable.green_leaves_small,
        R.drawable.moon_landscape_small,
        R.drawable.prismatic_floruish_small,
        R.drawable.technologic_small,
        R.drawable.white_small,
        R.drawable.red_small,
        R.drawable.bllue_small,
        R.drawable.yellow_small
};

到 string.xml 中的这个

<array name="drawable_positions">
    <item>@drawable/farm_small</item>
    <item>@drawable/scroll_small</item>
    <item>@drawable/desert_small</item>
    <item>@drawable/bg_blue_small</item>
    <item>@drawable/city_small</item>
    <item>@drawable/clip_small</item>
    <item>@drawable/grass_small</item>
    <item>@drawable/green_leaves_small</item>
    <item>@drawable/moon_landscape_small</item>
    <item>@drawable/prismatic_floruish_small</item>
    <item>@drawable/technologic_small</item>
    <item>@drawable/white_small</item>
    <item>@drawable/red_small</item>
    <item>@drawable/bllue_small</item>
    <item>@drawable/yellow_small</item>
</array>

我在这里初始化一切:imageID = res.getIntArray(R.array.drawable_positions);

但是现在当我用这些图像加入菜单时我看不到它们。我不知道为什么。

这是我的适配器:

RecyclerViewForBackground mAdapter = new RecyclerViewForBackground(web, imageID);

这是它的构造函数:

RecyclerViewForBackground(String[] web, int[] img) {
    this.web = web;
    this.img = img;
}

最佳答案

尝试使用integer-array标签而不是数组

关于java - 将 int[] 更改为 IntArray 导致无法在应用程序中加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41472005/

相关文章:

java - Java Maven 项目中 Jenkins 中带点的环境变量

android - API 级别 23 中的 getColor 错误

c - 如何将整数变量中的数字分配给字符串

PHP MySQL插入带有千位分隔符的整数

java - 无法在 powershell 中设置正确的编码

java - 如何在 Kotlin 中初始化一个线程?

java - Jframe JLabel,仅当我调整窗口大小时才刷新图像

android - 动态加载布局或选项

android - 调整 Android 多行 TextView 的大小

swift - 如何对二进制位数进行一些算术运算?