int image[] = {R.drawable.d002_p001,R.drawable.d002_p002,R.drawable.d002_p003,
R.drawable.d002_p004,R.drawable.d002_p005,R.drawable.d002_p006};
showPhoto(imCurrentPhotoIndex);
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("photo_index", imCurrentPhotoIndex);
super.onSaveInstanceState(outState);
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
imCurrentPhotoIndex = savedInstanceState.getInt("photo_index");
showPhoto(imCurrentPhotoIndex);
super.onRestoreInstanceState(savedInstanceState);
}
private void showPhoto(int photoIndex) {
ImageView imageView = (ImageView) findViewById(R.id.image_view);
// imageView.setImageResource(imPhotoIds[photoIndex]);
imageView.setImageResource(imPhotoIds[photoIndex]);
}
上面的代码用于从 drawable 文件夹中读取和显示图像。我想从存储卡中的文件夹中读取图像;我该做什么?