android 程序初始化界面.. .
来源:互联网 发布:深度卷积网络 dcnn 编辑:程序博客网 时间:2024/06/04 18:24
转自:http://menjoy.iteye.com/blog/1255291
启动界面的效果图:
启动界面
主要的实现类LoadingView :
- package wht.android.loading;
- import android.content.Context;
- import android.graphics.Canvas;
- import android.util.AttributeSet;
- import android.widget.ImageView;
- public class LoadingView extends ImageView implements Runnable
- {
- private boolean isStop = false;
- private int[] imageIds;
- private int index = 0;
- private int length = 1;
- public LoadingView(Context context)
- {
- this(context, null);
- }
- public LoadingView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- }
- public void setImageIds(int[] imageId)
- {
- this.imageIds = imageId;
- if(imageIds != null && imageIds.length > 0)
- {
- length = imageIds.length;
- }
- }
- @Override
- protected void onDetachedFromWindow()
- {
- // TODO Auto-generated method stub
- super.onDetachedFromWindow();
- isStop = true;
- }
- @Override
- protected void onDraw(Canvas canvas)
- {
- // TODO Auto-generated method stub
- super.onDraw(canvas);
- if(imageIds != null && imageIds.length > 0)
- {
- this.setImageResource(imageIds[index]);
- }
- }
- @Override
- public void run()
- {
- while(!isStop)
- {
- index = ++index % length;
- postInvalidate();
- try
- {
- Thread.sleep(400);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
- }
- public void startAnim()
- {
- new Thread(this).start();
- }
- }
MainActivity:
- package wht.android.loading;
- import android.app.Activity;
- import android.os.Bundle;
- public class MainActivity extends Activity
- {
- private LoadingView main_imageview;
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- main_imageview = (LoadingView)findViewById(R.id.main_imageview);
- initLoadingImages();
- new Thread()
- {
- @Override
- public void run()
- {
- main_imageview.startAnim();
- }
- }.start();
- }
- private void initLoadingImages()
- {
- int[] imageIds = new int[6];
- imageIds[0] = R.drawable.loader_frame_1;
- imageIds[1] = R.drawable.loader_frame_2;
- imageIds[2] = R.drawable.loader_frame_3;
- imageIds[3] = R.drawable.loader_frame_4;
- imageIds[4] = R.drawable.loader_frame_5;
- imageIds[5] = R.drawable.loader_frame_6;
- main_imageview.setImageIds(imageIds);
- }
- }
布局文件main.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:background="#e1e1e1">
- <wht.android.loading.LoadingView
- android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
- android:id="@+id/main_imageview" android:src="@drawable/loader_frame_1"
- android:layout_marginTop="190dp" android:layout_width="wrap_content"
- ></wht.android.loading.LoadingView>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="启动中..."
- android:layout_marginTop="10dip"
- android:textColor="#666666"
- android:layout_gravity="center_horizontal"
- android:textSize="20sp"
- />
- </LinearLayout>
0 0
- android 程序初始化界面..
- android 程序初始化界面.. .
- Android 程序界面
- android 程序启动界面
- android界面小程序
- AnimationDrawable android 动画 初始化界面播放
- android launcher开发(3)初始化界面
- Android init初始化程序分析
- Android程序界面主题切换
- Android 程序优化 - 界面布局
- 从零开始开发Android版2048 (一)初始化界面
- Android启动界面渐变及数据初始化处理
- Android 在程序界面上显示图片
- 第一个 android 的界面程序
- Android 在程序界面上显示图片
- 跳转到Android的程序卸载界面
- android 程序返回主界面方法
- android程序界面自动适应屏幕分辨率例子
- windows7/vs2008/32位程序/默认设置,new可分配最大空间
- 导出List列表中的数据到Excel文件,并提供下载
- Android 运行时找不到类:java.lang.NoClassDefFoundError:...
- 黑马程序员_02_模板方法模式
- Struts2 第一篇 Hello World
- android 程序初始化界面.. .
- UIPopoverController
- android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0
- 黑马程序员_03_享元设计模式Flyweight
- Integer与int的种种比较你知道多少?
- IOS7 UITableViewCellSelectionStyleBlue设置无效的替代方案。
- word中设置页眉页脚一些方法
- ret
- js apply/call/caller/callee/bind使用方法与区别分析