展会信息港展会大全

Android中layout.xml文件中加载自定义的View类
来源:互联网   发布日期:2015-10-13 14:58:26   浏览:1336次  

导读:View类的实现: package com.bn.summer; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Pain...

View类的实现:

package com.bn.summer;

import android.content.Context;

import android.content.res.Resources;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Canvas;

import android.graphics.Paint;

import android.util.AttributeSet;

import android.view.View;

public class GGView3 extends View{

int COMPONENT_WIDTH;

int COMPONENT_HEIGHT;

boolean initflag=false;

Bitmap[] bma;

Paint paint;

int[] drawablesId;

int currIndex=0;

boolean workFlag=true;

public GGView3(Context father,AttributeSet as)

{

super(father,as);

this.drawablesId=new int[]

{

R.drawable.room1,

R.drawable.room2,

R.drawable.room3,

};

bma=new Bitmap[drawablesId.length];

initBitmaps();

paint=new Paint();

paint.setFlags(Paint.ANTI_ALIAS_FLAG);//消除锯齿

new Thread()

{

public void run()

{

while(workFlag)

{

currIndex=(currIndex+1)%drawablesId.length;

GGView3.this.postInvalidate();

try

{

Thread.sleep(2500);

} catch (InterruptedException e)

{

e.printStackTrace();

}

}

}

}.start();

}

public void initBitmaps()

{

Resources res=this.getResources();

for(int i=0;i

赞助本站

人工智能实验室

相关热词: android开发

相关内容
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港