Android-activity program dynamic generation table layout Manager

Source: Internet
Author: User

. Java code is as follows:

Package Org.lxh.demo;import Android.app.activity;import Android.os.bundle;import android.view.viewgroup;import Android.widget.tablelayout;import Android.widget.tablerow;import Android.widget.textview;public Class Mytablelayoutdemo extends Activity {private String titledata[][] = new string[][] {{"ID", "name", "email", "address"},{"01", " Xiao Li "," [email protected] "," Beijing "},{" 02 "," Xiao Zhang "," [email protected] "," Tianjin "}; Define the data to be displayed @overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Tablelayout layout = new Tablelayout (this); Define table layout Tablelayout.layoutparams Layoutparam = new Tablelayout.layoutparams (ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); Define the layout manager's parameter//layout.setbackgroundresource (R.drawable.mldn_logo); Define the background picture for (int x = 0; x < this.titleData.length; + +) {//Loop Set table row TableRow row = new TableRow (this);//define Table row for (in T y = 0; Y < this.titledata[x].length; y++) {TextView text = new TextView (this); Text.settExt (this.titledata[x][y]); Set text content Row.addview (text, y); Add a number}layout.addview (row); Add a number of table rows to the table}super.setcontentview (layout, layoutparam); Settings Display}}


Code DOWNLOAD Link: http://download.csdn.net/detail/yayun0516/8362777

Android-activity program dynamic generation table layout Manager

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.