我想问一下如何实现倒数计时器来加载资产文件夹中的所有图像并根据设置的倒数时间显示它。例如,我的资产文件夹中有 5 张图像,我将它们放入数组中。每隔 5 秒,它将显示每个图像。例如:图像1> 5秒通过>图像2> 5秒通过>图像3等等......
下面是我的代码。请与我分享您的知识或任何实施方式。谢谢。
public class MainActivity extends AppCompatActivity {
private VrPanoramaView mVRPanoramaView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVRPanoramaView = (VrPanoramaView) findViewById(R.id.vrPanoramaView);
loadPhotoSphere();
}
private void loadPhotoSphere() {
VrPanoramaView.Options options = new VrPanoramaView.Options();
InputStream inputStream = null;
AssetManager assetManager=getAssets(); // to reach asset
try {
String[] images = assetManager.list("img");// to get all item in img folder.
options.inputType = VrPanoramaView.Options.TYPE_MONO;
for (int i = 0; i < images.length; i++) // the loop read all image in img folder
{
inputStream = getAssets().open("img/" + images[i]);
mVRPanoramaView.loadImageFromBitmap(BitmapFactory.decodeStream(inputStream), options);
}
}catch (IOException e) {
// you can print error or log.
e.printStackTrace();
}
}
}