ANDROID 自动生成动态表格for
简单的栗子去了解这个自动生成的动态的控件(自动生成表格)
/cs-Layout/res/layout/activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="请输入行:"
android:textSize="20sp" /> <EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="请输入数字!"
android:numeric="decimal" />
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" > <TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="请输入列:"
android:textSize="20sp" /> <EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="请输入数字!"
android:numeric="decimal" > <requestFocus />
</EditText>
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" > <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="一键自动生成表格" />
</LinearLayout>
</LinearLayout> <TableLayout
android:id="@+id/flout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TableLayout> </LinearLayout>
activity_main.xml
/cs-Layout/src/com/example/cs_layout/MainActivity.java
package com.example.cs_layout; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow; public class MainActivity extends Activity {
private Button submit;
private EditText cloumn;
private EditText run;
private TableLayout flout; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// cloumn = ;
submit = (Button) findViewById(R.id.button1);
cloumn = (EditText) findViewById(R.id.editText1);
run = (EditText) findViewById(R.id.editText2);
flout = (TableLayout) findViewById(R.id.flout); submit.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
flout.removeAllViews();
new MainActivity().shows(cloumn, run, flout, MainActivity.this); }
}); } public void shows(EditText cloumn, EditText run, TableLayout flout,
Activity a) {
int c = Integer.parseInt(cloumn.getText() + ""); // 将输入进来的数转整数
int r = Integer.parseInt(run.getText() + ""); TableLayout table = new TableLayout(a); // 表格布局
table.setWeightSum(1); // 权重
// table.setColumnStretchable(0, false);
for (int i = 0; i < c; i++) {
TableRow tr = new TableRow(a); for (int j = 0; j < r; j++) {
Button b = new Button(a); // b.setText(j);
tr.addView(b);
}
table.addView(tr);
}
flout.addView(table);
} public void color() { } }
MainActivity.java
ANDROID 自动生成动态表格for的更多相关文章
- android_demo之自动生成动态表格
今天我们学习了如何更好的利用Android 的 layout 布局. 接下来是个简单的栗子去了解这个自动生成的动态的控件(自动生成表格) 这是我们的layout 页面 <?xml version ...
- poi自动生成Ecxel表格和Chart图表
最近因为业务需求,需要做poi自动导出Ecxel表格和Chart折线图的功能. 所以我在网上找到了一篇关于poi生成Chart图表的博客,代码很详细,但是缺少相关注释说明. 想要将它改造成自己需要的样 ...
- Android 自动生成的R类
资源文件的使用分为在代码中使用和在其他资源文件中引用该资源文件.在我们编译一个Android应用时,Android会自动生成一个R类,在该类中根据不同的资源类型又生成了相应的内部类,该类包含了系统中使 ...
- 结队编程第二次作业:Android自动生成算式应用
一.题目要求 本次作业要求两个人合作完成,驾驶员和导航员角色自定,鼓励大家在工作期间角色随时互换,这里会布置两个题目,请各组成员根据自己的爱好任选一题. 这次我和我的小伙伴选择了题目一. 题目1: 实 ...
- Android 自动生成表格
Layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:a ...
- 自己写的自动生成动态边框的jquery小插件
思路就是在元素四周添加<ul>列表,然后周期性地改变它的颜色,实现动态的效果,不支持ie7.ie8 预览链接http://gorey.sinaapp.com/myBorder/border ...
- android 自动生成jni C语言头文件
1. 在类里面申明 public native xxx(); 函数接口2. 在安卓工程src目录下 使用命令 javah 包名.类名 生成该类所申明的c语言接口
- jmeter自动生成报告
从JMeter 3.0开始已支持自动生成动态报告,我们可以更容易根据生成的报告来完成我们的性能测试报告. 如何生成html测试报告 如果未生成结果文件(.jtl),可运行如下命令生成报告: jmete ...
- Jmeter系列-自动生成html报告
从JMeter 3.0开始已支持自动生成动态报告,我们可以更容易根据生成的报告来完成我们的性能测试报告. 如何生成html测试报告 如果未生成结果文件(.jtl),可运行如下命令生成报告: jmete ...
随机推荐
- windows 编程 —— 菜单以及其他资源
目录: 1.资源的种类 2.资源的定义方法(IDE:VC++) 3.资源的获取 4.资源的使用与消息处理函数 1.资源的种类 windows 的常用的资源包括:图示 .游标. 字符串. 自订资源. ...
- Android学习之电话拨号器
本人自己是做android驱动的,也会接触到系统层.上层的应用,所以在闲暇的时候也就开始了学习android应用的路程,在这里把这些东西记下来,希望自己能坚持下去,也好以后复习用. 今天先实现一个简单 ...
- 一个非常有趣的算法程序(有趣只针对程序猿)就是Josephus问题
大概花了一个晚上搭一个中午的时间,完善了一个关于Josephus的程序,这个Josephus游戏可是非常经典的算法,作为一个想从事软件的人最好能够理解一下,毕竟这个计算机教材上也讲过类似题目,具体的关 ...
- 通知中心 NSNotificationCenter
NSNotificationCenter 通知中心提供了一种在程序内广播信息的途径,一个NSNotificationCenter对象本质上是一个通知分发表(notification dispatch ...
- IIS部署FTP服务器步骤
本文介绍如何在IIS中部署FTP服务端.首先确认windows开启了ftp功能:确认方法:进入控制面板->程序->打开或关闭windows功能如下图所示: 确认FTP勾选 确认后打开IIS ...
- Creating Lists and Cards 创建列表和卡片
To create complex lists and cards with material design styles in your apps, you can use the Recycler ...
- NYOJ 1091 超大01背包(折半枚举)
这道题乍一看是普通的01背包,最最基础的,但是仔细一看数据,发现普通的根本没法做,仔细观察数组发现n比较小,利用这个特点将它划分为前半部分和后半部分这样就好了,当时在网上找题解,找不到,后来在挑战程序 ...
- Linux下用rpm方式安装MySQL
1.MySQL下载地址. www.mysql.com/downloads/mysql-4.0.html 下载MySQL 5.1版本的2个包(根据你的实际需求下载所需要的包): MySQL-server ...
- 一览css布局标准
回顾历史,CSS1于1996.12.17发正式版,它是为辅助HTML的展现效果而生的.1998.5.12,CSS2发正式版.随后发修订版CSS2.1,纠正了CSS2中的一些错误.注意从CSS2起,CS ...
- 简单竖向Tab选项卡
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...