我正在尝试在SD卡中显示文件夹中的图像。从xml文件中读取有关图像的信息。以下代码显示没有错误,但imageview不显示任何空白。请帮我找到原因。
public class Fadeinlogo_fragment extends Fragment{
int currentimageindex=0;
int imageindex =0;
Bitmap[] imageidlist;
ImageView slidingimage;
static int fadeinimageindex=0;
String[] fadeinimagelist;
String[] fadeinimagepath;
File fadeinimageFiles;
Animation animrotate;
String[] Imagepath;
String Systemroot;
List<Schedule> FadeInImagePathlist;
int CurrentLogoImageindex=0;
Bitmap[] FadeInimageidlist;
ImageView imgView;
private void getImagepaths(){
Systemroot =Environment.getExternalStorageDirectory().getAbsolutePath();
Log.d("sytempath",Systemroot);
String filePath=Systemroot + "/fadeinimages" + "/fadeinimages.xml";
ScheduleParser schedulexml=new ScheduleParser();
FadeInImagePathlist = new ArrayList<Schedule>();
FadeInImagePathlist= schedulexml.getSchedule(getActivity(), filePath);
Imagepath=new String[FadeInImagePathlist.size()];
FadeInimageidlist=new Bitmap[FadeInImagePathlist.size()];
Log.d("inside get images",Systemroot);
for(int i=0;i<FadeInImagePathlist.size();i++)
{
Imagepath[i] = Systemroot + "/fadeinimages/" + FadeInImagePathlist.get(i).getFileName();
Log.e("logoimagepath:"+i+" Filename",Imagepath[i]);
FadeInimageidlist[i] = BitmapFactory.decodeFile(Imagepath[i]);
}
}
private void fadeinthread(){
final Handler mHandler = new Handler();
final Runnable mUpdateResults = new Runnable() {
public void run() {
SlideShow();
}
};
int delay = 0;
int period = 15000;
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
mHandler.post(mUpdateResults);
}
}, delay, period);
}
private void SlideShow()
{
animrotate = AnimationUtils.loadAnimation(getActivity(),R.anim.slide_in);
imgView.setImageBitmap(FadeInimageidlist[fadeinimageindex]);
fadeinimageindex++;
if(fadeinimageindex==FadeInimageidlist.length)
fadeinimageindex=0;
imgView.startAnimation(animrotate);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView= inflater
.inflate(R.layout.fadeinlogo_fragment, container, false);
imgView = (ImageView)rootView.findViewById(R.id.fadeinlogoimageView);
DisplayMetrics displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width/5,height/5);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
imgView.setLayoutParams(params);
getImagepaths();
fadeinthread();
return rootView;}}