我想要这样做:
Integer[] 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
};
我在一个类中使用Integer []并且我在片段运行时创建了它,所以需要一些时间
像这样:<string-array name="background_name">
<item>Farm Land</item>
<item>Scroll</item>
<item>Desert</item>
<item> Magic Blue</item>
<item>Old City</item>
<item>Clip Board</item>
<item>Grass</item>
<item>Green Leaves</item>
<item>Moon Landscape</item>
<item>Prismatic Flourish</item>
<item>Technologic</item>
<item>White</item>
<item>Red</item>
<item>Blue</item>
<item>Yellow</item>
</string-array>
这是在数组列表中声明Integer []的最佳实践吗?
答案 0 :(得分:4)
是的,你可以这样做
cp geckodriver.exe \path\to\Python\
你可以像这样以编程方式获取它
<integer-array name="background_name">
<item>@drawable/farm_small </item>
</integer-array>
答案 1 :(得分:1)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="imageID">
<item>@drawable/farm_small</item>
.
.
.
<item>@drawable/farm_smalln</item>
</array>
</resources>