我是为 android 开发应用程序的新手,我需要一些帮助。
我需要为所有活动从 SDCARD 中的特定路径文件夹中的页脚动画图像,我使用页脚布局作为所有布局的通用。
我通过编写以下代码编写了用于动画图像的代码:
public void AnimateActionHandler() {
try {
Toast.makeText(this, "My Service AnimateActionHandler", Toast.LENGTH_LONG).show();
final Handler mHandler = new Handler();
final Runnable mUpdateResults = new Runnable() {
public void run() {
AnimateandSlideShow();
}
};
int delay = 500; // delay for 1 sec.
int period = 1000; // repeat every 2 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
mHandler.post(mUpdateResults);
}
}, delay, period);
} catch (Exception e) {
// TODO: handle exception
}
}
public void AnimateandSlideShow() {
try {
Toast.makeText(this, "My Service AnimateandSlideShow", Toast.LENGTH_LONG).show();
if (Config.ImageFilelist.isEmpty()) {
Config.ImageFilelist = GetFileList(AddsPath);
}
if (Config.ImageFilelist.size() <= Config.currentimageindex) {
Config.currentimageindex = 0;
}
Toast.makeText(this, "ImageFilelist::"+Config.ImageFilelist.size(), Toast.LENGTH_LONG).show();
Log.d(TAG, "Config.currentimageindex::"+Config.currentimageindex);
Config.FooterBitmap = BitmapFactory.decodeFile(Config.ImageFilelist.get(Config.currentimageindex).toString());
Log.d(TAG, "Addbmp"+Config.FooterBitmap.getHeight());
Config.slidingimage = (ImageView) findViewById(R.id.goeasy_footer);
Config.slidingimage.setImageBitmap(Config.FooterBitmap);
Log.d(TAG, "JOSEafter");
Animation rotateimage = AnimationUtils.loadAnimation(this,R.anim.splash_anim);
Config.slidingimage.startAnimation(rotateimage);
Config.currentimageindex = Config.currentimageindex + 1;
if (Config.ImageFilelist.size() <= Config.currentimageindex) {
Config.currentimageindex = 0;
}
} catch (Exception e) {
Log.e(TAG, "Set image EXC"+e.toString());
e.printStackTrace();
// TODO: handle exception
}
catch (OutOfMemoryError oe) {
try{
}
catch (Exception e) {
// TODO: handle exception
}
// TODO: handle exception
}
}
现在我想通过服务在所有屏幕的页脚中播放这个动画,我该如何解决这个问题,任何人都可以帮助我。