我正在处理Android图片的选框。我实现了AutoSlider,但无法调用活动。下面是我的Autoslider代码。 我正在开发一个应用程序,我需要一个从屏幕左侧浮动到屏幕右侧的图像。有谁能够帮我?如何从左到右浮动一些图像,反之亦然? Image应像浮点一样浮动,就像在HTML中一样。它们应从屏幕左侧开始,在屏幕右侧结束。我想在Android中使用类似的东西。
package com.hp.smartedi.activities;
import java.util.Timer;
import java.util.TimerTask;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageView;
import com.hp.smartedi.R;
public class Autoslider extends LoginActivity{
public int currentimageindex=0;
Timer timer;
TimerTask task;
ImageView slidingimage;
int[] IMAGE_IDS = {R.drawable.splash_se};
@Override
public void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Handler mHandler = new Handler();
// Create runnable for posting
final Runnable mUpdateResults = new Runnable() {
public void run() {
AnimateandSlideShow();
}
};
int delay = 1000; // delay for 1 sec.
int period = 8000; // repeat every 4 sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
mHandler.post(mUpdateResults);
}
}, delay, period);
}
public void onClick(View v) {
finish();
android.os.Process.killProcess(android.os.Process.myPid());
}
private void AnimateandSlideShow() {
slidingimage = (ImageView)findViewById(R.id.app);
slidingimage.setImageResource(IMAGE_IDS[currentimageindex%IMAGE_IDS.length]);
currentimageindex++;
}
}
请帮助我:我应该如何在LoginActivity中调用AutoSlider?