Android中的TableLayout的简单使用

摘要:
Android中TableLayout的简单使用为Layout添加了TableLayout控件。

Android中的TableLayout的简单使用

在Layout中加入TableLayout控件。

    <TableLayout android: 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40dp"
        android:layout_marginTop="157dp" >
    </TableLayout>

Code

public class MainActivity extends Activity {
	private final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;  
    private final int FP = ViewGroup.LayoutParams.FILL_PARENT;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		TableLayout myTableLayout = (TableLayout)this.findViewById(R.id.myTableLayout);
		//全部列自动填充空白处  
		myTableLayout.setStretchAllColumns(true);	
		for(int r = 1; r < 10; r ++)
		{
			TableRow tr = new TableRow(this); 
			for(int c = 1; c < 5; c++)	  
			{		
				TextView tv = new TextView(this);
				tv.setText("Row " + r + "  + Column " + c );  
				tr.addView(tv);
			}
			myTableLayout.addView(tr,new TableLayout.LayoutParams(FP, WC));  
		}	
	}
}

 效果图

Android中的TableLayout的简单使用第1张

免责声明:文章转载自《Android中的TableLayout的简单使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇React Native使用 DeviceEventEmitter发送通知emit和监听接收addListener的用法从点击Button到弹出一个MessageBox, 背后发生了什么下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

让x86的android模拟器能模拟arm架构系统

2019年展月6日更新: 1、最近发现了一个能在linux下模拟arm的模拟器: xdroid,网址: https://www.linzhuotech.com/index.php/home/index/down.html, 特别好用。直接模拟arm。我的云盘里有其可执行程序。 (这个需要 5G 的根目录空间,不推荐,太大了,这个是linux上运行,不是模拟...

(三)android布局基础及范例:人人android九宫格布局(转载http://blog.csdn.net/jiabinjlu/article/details/6921008)

人人android是人人网推出的一款优秀的手机应用软件,我们在使用的时候发现他的首页布局是九宫格模式的,让人觉得很别致,因为现在很多的android软件很少使用这种布局模式,人人android使用的很成功,使人觉得简洁大方美观,下面我们来看看人人android的布局 其实这种布局是使用了一种叫“GridView”的表格布局,下面我来给大家讲一下: 首先,...

如何生成Android签名证书、安卓签名获取工具获取APP签名报错:NameNotFoundException: Signs is null的问题

  每个安卓APP,都要签名证书才能安装在手机上,测试的应用有测试的签名证书,生产环境有生产环境的签名证书,在开发APP之前,我们首先生成一个用于该APP的签名证书,用于测试调试应用,像微信支付、分享、地图,这些等等都需要用到生产环境的签名证书。   生成 Android 签名文件,目前有两种一种是 eclipse 开发工具生成的后缀名  .keystor...

安卓 节点进度条NodeProgressBar

安卓节点进度NodeProgressBar条如图:  NodeProgressView.class 文件代码 import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graph...

Android四大组件--Broadcast Receiver具体解释

本文主要讲述了: 一、BroadcastReceiver概述: 二、BroadcastReceiver事件分类 三、BroadcastReceiver事件的编程流程 四、两类BroadcastReceiver 五、普通广播和有序广播 六、Service与BroadcastReceiver怎样交互? 七、开机自己主动执行service 八、Broadcas...

Unity调用安卓Android的Toast

需求:在游戏中弹窗消息,调起安卓的Toast 项目中需要做Unity和安卓交互时,经常需要通过安卓Toast来做简单的输出,以便于测试。 方法一:Unity中,C#主导 //Unity调用安卓的土司 public static void MakeToast(stringinfo) { AndroidJavaClass unityPla...