如何在滑块视图中显示来自特定内部目录的所有图像?
How to display all images from a particular internal directory in a Slider view?
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.
我已经解决了这个问题 problem.Just 替换这一行
.image(Hash_file_maps.get(name))
和
.image(new File(Hash_file_maps.get(name)))
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.
我已经解决了这个问题 problem.Just 替换这一行
.image(Hash_file_maps.get(name))
和
.image(new File(Hash_file_maps.get(name)))