tutorial on the use of Egret egret.gui.List

Source: Internet
Author: User

Tool: Egretwing

Description

List component

Itemrender List Item Component

Here's how to bind the data to the list and correspond to the Itemrender display.

/** * created by haocao on 15/6/25. */class  friendslistcase  extends egret.gui.skinnablecomponent{    public constructor () {         super ();         this.skinname  = skins.scene.FriendsListSkin;        //  Initialize data          this.initlistdata ();    }    list    public listview:egret.gui.list;    //of the  //  binding interface   Data array    private datasource:array<any> = [];     private initlistdata ():void {        for  ( var i:number = 1; i < 50; i++)  {            thiS.datasource.push ({name:  "name" +i,phone: "A" +I,QQ: "B" +i});         }    }    public partadded (Partname:string, instance:any): Void {        super.partadded (partname, instance);         if  (Instance == this.listview)  {             //  Binding Data Sources              this.listview.dataprovider = new egret.gui.arraycollection ( This.datasource);                        //  binding itemview             this.listview.itemrenderer= new egret.gui.classfactory ( Frienditemrender);          }    }} 
/** * *  @caohao   * */class FriendItemRender extends  egret.gui.itemrenderer{        public lname:egret.gui.label; &NBSP;&NBSP;&NBSP;&NBSP;PUBLIC&NBSP;LPHONE:EGRET.GUI.LABEL;&NBSP;&NBSP;&NBSP;&NBSP;PUBLIC&NBSP;LQQ: Egret.gui.label;        public constructor ()  {         super ();        //  Skin name          this.skinName = skins.scene.FriendsListItemSkin;         this.touchChildren = true;    }         public datachanged ():void{         //  map data to Components         this.lname.text =  this.data.name;        this.lphone.text = this.data.phone;         this.lqq.text = this.data.qq;    }    }


Eventually:


Reference article:

Http://bbs.egret-labs.org/thread-1055-1-1.html

tutorial on the use of Egret egret.gui.List

Related Article

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.