Just like HTML Tables on webpages the TableLayout on Android gives you the option to align Views in a table order with rows and columns.
My development setup is:IDE: Eclipse IDE (setup guide here
).
Phone: HTC Hero
Android version: 1.5 HTC Rom
I will be using the standard Android Project Skeleton in Eclipse as my base setup. This auto creates all the basic files needed, so these will not be covered here.
TableLayout on Android
The TableLayout is built using the TableLayout and the TableRow commands. There is no TableCols like the <td> tag in HTML. To align your view in columns you have to set the width of the elements and manually control the layout.
XML Layout
To make a basic layout with 2 rows and 4 textview I have a main.xml with this content:
This creates a layout like this:
So we have now displayed a simple TableLayout.
Right aligning checkboxes
Many apps have a nice clean setup where the checkboxes is right aligned to the screen and this is actually very easy to achieve. You just have to set the width of the textview so it will push the checkbox to the right.
First step is to change the TextView02 to a Checkbox like this:
This will output somethings like this:
Now we just have to align the checkbox.
We can do this by setting the width of the previous textfield like this:
Notice the width=”250px”
in the end there. This results in:
But what is the screen size changes? The checkbox will then be placed 250px from the left because the width is hardcoded. Not that great – but yet very easy to adjust.
On the LayoutTable we can adjust stretching across columns, similar to the colspan tag in HTML.
This will make the first (“0″) column stretch as most as needed and allowed by the other elements.:
And with the screen flipped:
Complete XML layout:
Appending rows dynamically
Lets say you want to add rows to the TableLayout on depend during your app. No problem.
Add a button at the top of your application like this:
There is now a button available for handling clicks from the user and the TableLayout has been wrapped in a ScrollView which enables the scroll functionality.
Now for some Java code
So whenever the button is clicked, it adds a new row to the TableLayout and notice the Scrollbar from the ScrollView.
If you want more information and TableLayout and placement techniques I can recommend reading:
Thats it for now. Enjoy coding and please post some comments.
andorid2.3的系统不支持jdk1.5版本,必须升级到1.6版本。
1:从官方网站下载1.6版本的jdk,我的是jdk-6u25-linux-i586.bin
2:将jdk-6u25-linux-i586.bin复制粘贴到/home/usr/目录下(也可以自己新建一个目录)
3:启动终端:输入命令cd /home/usr
4:sudo -s ./jdk-6u25-linux-i586.bin
5:接着一路回车
6:待上面的运行完成后,在/home/.bashrc文件中配置jvm的环境变量
7:cd ~
8: vim .bashrc
9:在文件的最后一行加入以下内容:
export JAVA_HOME=/home/usr/jdk1.6.0_25
export JRE_HOME=/home/usr/jdk1.6.0_25/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
10:保存后退出,重新启动电脑
11:查看jdk版本:java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Server VM (build 20.0-b11, mixed mode)
转自:http://www.mcncc.com/read-htm-tid-21378.html
1.修改/etc/sysconfig/displaymanager
DISPLAYMANAGER_REMOTE_ACCESS="yes"
DISPLAYMANAGER_ROOT_LOGIN_REMOTE="yes"
DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN="yes"
2.相应的配置文件/etc/gdm/custom.conf也会更改成如下样子
# GDM configuration storage
[xdmcp]
# SuSEconfig: displaymanager:DISPLAYMANAGER_REMOTE_ACCESS
Enable=true
Port=177
[chooser]
[security]
# SuSEconfig: displaymanager:~DISPLAYMANAGER_XSERVER_TCP_PORT_6000_OPEN
DisallowTCP=false
# SuSEconfig: displaymanager:DISPLAYMANAGER_ROOT_LOGIN_REMOTE
AllowRemoteRoot=true
[debug]
3.然后,更改/etc/X11/xdm/xdm-config,注销掉这一行(在起点加以个!)
! DisplayManager.requestPort: 0
4.重启xdm
# /etc/init.d/xdm restart
然后可以在windows下安装XManager之类的软件来远程控制suse了
XManager Enterprise 3.0.0234最新注册码_XManager注册码免破解
先来5组号吧,用户名组织都是www.budingwang.com
Serial:100501-116431-000686
Serial:100501-116421-000966
Serial:100501-156941-000646
Serial:100501-156991-000134
Serial:100501-116391-000542