如题。
比如一个登陆窗口,点击登陆页面后,在于服务器连接的过程中,显示进度条或者圆圈转动的等待状态。
当接收到服务器返回的信息后,进度条消失,进入下一个页面。
望高手不吝赐教!
------解决方案--------------------
以前做项目的时候实现过一个,也是从别处copy来的,你改动一下就应该符合你的要求了
import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;
public class LoaderScreen extends MainScreen {
/**
* 单例对象
*/
private static LoaderScreen instance;
/**
* 获取单实例对象
*
*/
public static LoaderScreen getInstance()
{
if (instance == null)
{
instance = new LoaderScreen("Please wait...");
}
return instance;
}
Timer loadingTimer = new Timer();
TimerTask loadingTask;
int imageIndex = 0;
Bitmap loader1 = Bitmap.getBitmapResource("loader001.png");
Bitmap loader2 = Bitmap.getBitmapResource("loader002.png");
Bitmap loader3 = Bitmap.getBitmapResource("loader003.png");
Bitmap loader4 = Bitmap.getBitmapResource("loader004.png");
Bitmap loader5 = Bitmap.getBitmapResource("loader005.png");
Bitmap loader6 = Bitmap.getBitmapResource("loader006.png");
Bitmap loader7 = Bitmap.getBitmapResource("loader007.png");
Bitmap loader8 = Bitmap.getBitmapResource("loader008.png");
Bitmap loader9 = Bitmap.getBitmapResource("loader009.png");
Bitmap loader10 = Bitmap.getBitmapResource("loader010.png");
Bitmap loader11 = Bitmap.getBitmapResource("loader011.png");
Bitmap loader12 = Bitmap.getBitmapResource("loader012.png");
boolean showLoader = false;
int xAnchor = (Display.getWidth()-200)/2;
int yAnchor = ((Display.getHeight())>>2) * 3;
String loaderText;
public LoaderScreen( String loaderText) {
super();
// 设置背景
VerticalFieldManager _fieldManagerBkg = (VerticalFieldManager) getMainManager();
_fieldManagerBkg.setBackground(BackgroundFactory
.createSolidBackground(Color.CHOCOLATE));
this.loaderText = loaderText;
loadingTask = new TimerTask() {
public void run() {
invalidate();
imageIndex++;
if(imageIndex == 11){
imageIndex = 0;
}
}
};
loadingTimer.scheduleAtFixedRate(loadingTask, 100, 100);
}
public void setShowLoader(boolean showLoader) {
this.showLoader = showLoader;
}
public boolean isShowing(){
return showLoader;
}
protected void paint(Graphics graphics) {
super.paint(graphics);
if (showLoader) {
//draw background:
graphics.setColor(0x363636);
graphics.fillRect(xAnchor, yAnchor, 200, 40);
//draw animation frame:
switch (imageIndex) {
case 0:
graphics.drawBitmap(xAnchor + 4, yAnchor + 4, 32, 32, loader1, 0, 0);
break;
case 1:
graphics.drawBitmap(xAnchor + 4, yAnchor + 4, 32, 32, loader2, 0, 0);
break;
case 2:
graphics.drawBitmap(xAnchor + 4, yAnchor + 4, 32, 32, loader3, 0, 0);