我已尝试使用Picasso从资源文件夹中加载图像
下面是java代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_frame);
getFilesList();
ivMain = (ImageView) findViewById(R.id.ivMain);
Picasso.with(MainFrameActivity.this)
.load("file:///android_asset/" + files.get(0)).into(ivMain);
}
private void getFilesList() {
try {
files = new ArrayList<String>();
String f[] = getAssets().list("");
for (String f1 : f) {
if (f1.endsWith(".png")) {
System.out.println(f1);
files.add(f1);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println中的我正在获取.png文件列表
02-10 23:04:16.229: I/System.out(5863): a1_big.png
02-10 23:04:16.229: I/System.out(5863): a_big.png
02-10 23:04:16.229: I/System.out(5863): b1_big.png
02-10 23:04:16.229: I/System.out(5863): b_big.png
02-10 23:04:16.229: I/System.out(5863): c1_big.png
02-10 23:04:16.229: I/System.out(5863): c_big.png
02-10 23:04:16.229: I/System.out(5863): d1_big.png
02-10 23:04:16.229: I/System.out(5863): d_big.png
02-10 23:04:16.229: I/System.out(5863): e1_big.png
02-10 23:04:16.229: I/System.out(5863): e_big.png
02-10 23:04:16.229: I/System.out(5863): f1_big.png
02-10 23:04:16.229: I/System.out(5863): f_big.png
02-10 23:04:16.229: I/System.out(5863): g1_big.png
02-10 23:04:16.229: I/System.out(5863): g_big.png
02-10 23:04:16.229: I/System.out(5863): h1_big.png
02-10 23:04:16.229: I/System.out(5863): h_big.png
但它没有在ivMain中加载,是否有人有解决方案?