Building Compound Components for Android

Source: Internet
Author: User

Package andorid. J. awin;

Import Android. content. context;
Import Android. Graphics. Canvas;
Import Android. util. attributeset;
Import Android. View. view;
Import Android. View. viewgroup. layoutparams;
Import Android. widget. Button;
Import Android. widget. edittext;
Import Android. widget. linearlayout;
/*
* Create by danielinbiti
*/
Public class edittextbtn extends linearlayout {
Button button = NULL;
Edittext = NULL;
Public edittextbtn (context ){
Super (context );
This. INIT (context );

}
Public edittextbtn (context, attributeset attrs ){
Super (context, attrs );
This. INIT (context );

}
Private void Init (context ){
Button = new button (context );
Edittext = new edittext (context );

This. setorientation (linearlayout. Horizontal );
This. setlayoutparams (New linearlayout. layoutparams (layoutparams. fill_parent, 50 ));
Linearlayout. layoutparams = new linearlayout. layoutparams (layoutparams. wrap_content, layoutparams. fill_parent );
Layoutparams. Weight = 1;
This. addview (edittext, layoutparams );
Linearlayout. layoutparams layoutparamsbtn = new linearlayout. layoutparams (50, layoutparams. fill_parent );
Button. setheight (edittext. getheight ());
This. addview (button, layoutparamsbtn );

}
Public void onbuttonclick (){
Button. setonclicklistener (New View. onclicklistener (){

@ Override
Public void onclick (view v ){
Edittext. settext ("test danielinbiti ");
}
});
}

}

// When used in code

Edittextbtn = new edittextbtn (this );

Add it to the layout. If it is defined in XML

The above code is mainly a simple example, a combination of components.

Works:

Classic childhood games (table games monopoly)-meters integral wall (http://d.1tpan.com/tp1858802400)

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.