gpt4 book ai didi

android - 如何在 slider View 中显示来自特定内部目录的所有图像?

转载 作者:行者123 更新时间:2023-11-30 00:13:27 25 4
gpt4 key购买 nike

I trying to display images from particular directory. Getting length and image names and I could not able to display images. I tried like this.

public class MainActivity extends AppCompatActivity implements BaseSliderView.OnSliderClickListener, ViewPagerEx.OnPageChangeListener{
SliderLayout sliderLayout;
HashMap<String,String> Hash_file_maps ;
ImageView Image_view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
Hash_file_maps = new HashMap<String, String>();
sliderLayout = (SliderLayout)findViewById(R.id.slider);
File file=new File("/storage/emulated/0/Pictures/NC");
File[] list = file.listFiles();
int count = 0;
for (File f: list){
String name = f.getName();
if (name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".png"))

Hash_file_maps.put("",file.getName());

            count++;
}
for(String name : Hash_file_maps.keySet()){
TextSliderView textSliderView = new TextSliderView(MainActivity.this);
textSliderView
.description(name)
.image(Hash_file_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);
textSliderView.bundle(new Bundle());
textSliderView.getBundle()
.putString("extra",name);
sliderLayout.addSlider(textSliderView);
}
sliderLayout.setPresetTransformer(SliderLayout.Transformer.Accordion);
sliderLayout.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
sliderLayout.setCustomAnimation(new DescriptionAnimation());
sliderLayout.setDuration(10000);
sliderLayout.addOnPageChangeListener(this);
}
@Override
protected void onStop() {
sliderLayout.stopAutoCycle();
super.onStop();
}

Could you please help me.

最佳答案

我已经解决了这个问题。只需替换这一行

.image(Hash_file_maps.get(name))

.image(new File(Hash_file_maps.get(name)))

关于android - 如何在 slider View 中显示来自特定内部目录的所有图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47749031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com