当前位置:  编程技术>移动开发
本页文章导读:
    ▪动态增多TableLayout的行        动态增加TableLayout的行 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 Andr.........
    ▪ Ubuntu上安装jdk1.6        Ubuntu下安装jdk1.6 andorid2.3的系统不支持jdk1.5版本,必须升级到1.6版本。1:从官方网站下载1.6版本的jdk,我的是jdk-6u25-linux-i586.bin2:将jdk-6u25-linux-i586.bin复制粘贴到/home/usr/目录下(也可以自己.........
    ▪ Xmanager 联接 SUSE11       Xmanager 连接 SUSE11   转自: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.相应的.........

[1]动态增多TableLayout的行
    来源: 互联网  发布时间: 2014-02-18
动态增加TableLayout的行

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:

< TableLayout android:id = "@+id/TableLayout01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
 
   < TableRow android:id = "@+id/TableRow01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
 
     < TextView android:id = "@+id/TextView01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 1-1" ></ TextView >
     < TextView android:id = "@+id/TextView02" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 1-2" ></ TextView >
 
   </ TableRow >
 
   < TableRow android:id = "@+id/TableRow02" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
 
     < TextView android:id = "@+id/TextView03" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 2-1" ></ TextView >
     < TextView android:id = "@+id/TextView04" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 2-2" ></ TextView >
 
   </ TableRow >
 
</ TableLayout >

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:

...
     < TextView android:id = "@+id/TextView01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 1-1" ></ TextView >
     < CheckBox android:id = "@+id/CheckBox01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" ></ CheckBox >

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:

< TableRow android:id = "@+id/TableRow01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >< TextView android:id = "@+id/TextView01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 1-1" android:width = "250px" ></ TextView >

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.

...
< TableLayout android:id = "@+id/TableLayout01" android:layout_width = "fill_parent" android:layout_height = "wrap_content"   android:stretchColumns = "0" >
...

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:

<? xml version = "1.0" encoding = "utf-8" ?>
< LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android "
     android:orientation = "vertical"
     android:layout_width = "fill_parent"
     android:layout_height = "fill_parent"
     >
 
< TableLayout android:id = "@+id/TableLayout01" android:layout_width = "fill_parent" android:layout_height = "wrap_content"   android:stretchColumns = "0" >
 
   < TableRow android:id = "@+id/TableRow01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
     < TextView android:id = "@+id/TextView01" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "textfield 1-1" ></ TextView >
 
     < CheckBox android:id = "@+id/CheckBox01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" ></ CheckBox >
   </ TableRow >
 
   < TableRow android:id = "@+id/TableRow02" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
     < TextView android:id = "@+id/TextView03" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 2-1" ></ TextView >
     < TextView android:id = "@+id/TextView04" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "textfield 2-2" ></ TextView >
 
   </ TableRow >
 
</ TableLayout >
</ LinearLayout >

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:

< Button android:id = "@+id/Button01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "Add row" ></ Button >
 
< ScrollView android:id = "@+id/ScrollView01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
 
   < TableLayout android:id = "@+id/TableLayout01" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:stretchColumns = "0" >
 
     < TableRow android:id = "@+id/TableRow01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" >
       < TextView android:id = "@+id/TextView01" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "textfield 1-1" ></ TextView >
 
       < CheckBox android:id = "@+id/CheckBox01" android:layout_width = "wrap_content" android:layout_height = "wrap_content" ></ CheckBox >
     </ TableRow >
 
   </ TableLayout >
</ ScrollView >

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

package huuah.tablelayout;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.View;
 
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TableRow;
import android.widget.TableRow.LayoutParams;
 
public class tablelayout extends Activity implements OnClickListener {
     /** Called when the activity is first created. */
 
     //initialize a button and a counter
     Button btn;
     int counter = 0 ;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super .onCreate(savedInstanceState);
 
         // setup the layout
         setContentView(R.layout.main);
 
         // add a click-listener on the button
         btn = (Button) findViewById(R.id.Button01);
         btn.setOnClickListener( this );       
 
     }
 
     // run when the button is clicked
     public void onClick(View view) {
 
         // get a reference for the TableLayout
         TableLayout table = (TableLayout) findViewById(R.id.TableLayout01);
 
         // create a new TableRow
         TableRow row = new TableRow( this );
 
         // count the counter up by one
         counter++;
 
         // create a new TextView
         TextView t = new TextView( this );
         // set the text to "text xx"
         t.setText( "text " + counter);
 
         // create a CheckBox
         CheckBox c = new CheckBox( this );
 
         // add the TextView and the CheckBox to the new TableRow
         row.addView(t);
         row.addView(c);
 
         // add the TableRow to the TableLayout
         table.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
 
     }
}

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.

原文:http://huuah.com/using-tablelayout-on-android/

    
[2] Ubuntu上安装jdk1.6
    来源: 互联网  发布时间: 2014-02-18
Ubuntu下安装jdk1.6
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)

    
[3] Xmanager 联接 SUSE11
    来源: 互联网  发布时间: 2014-02-18
Xmanager 连接 SUSE11

 

转自: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


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3