Load the custom View class in the layout. xml file in Android

Source: Internet
Author: User

      
 



View class implementation:

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); // remove the 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
 
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.