正如标题所说,当我尝试填充数组时,我的代码失败了,但它只适用于一项
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int width=getWidth(this);
int height=getHeight(this);
String resolution= new String();
tamanhos= new String[]{ "240x320","320x480","480x800","800x1280"};
wallpapers= new String[]{ "fdonegrobrillo"};
resolution=tamanhos[3]
mImages=new int[wallpapers.length];
Resources res= this.getResources();
for(int i=0;i<wallpapers.length;i++){
mImages[i]=res.getIdentifier(wallpapers[i]+resolution, "drawable",this.getPackageName());
}
我有所有相应的可绘制对象。当我尝试只使用一个项目时,应用程序可以工作,但如果我将另一个项目添加到壁纸数组,它会引发错误(致命信号 11(SIGSEGV))
我尝试使用这样的硬编码数组
mImages=new int[]{
this.getResources().getIdentifier("fdobyn800x1280",
"drawable", this.getPackageName())
};
我工作,但是当我添加另一个项目时它是一样的
mImages=new int[]{
this.getResources().getIdentifier("fdobyn800x1280",
"drawable", this.getPackageName()),
this.getResources().getIdentifier("fdonegrobrillo800x1280",
"drawable", this.getPackageName())
};