garfieldtom

 

2012年5月2日

Android布局学习

习惯了Delphi/VB等RAD的拖放布局,使用Android的布局管理器还真不习惯.

例如要实现下面的界面布局: 


则需要如下设置:

 1 <LinearLayout
 2         android:layout_width="wrap_content"
 3         android:layout_height="wrap_content"
 4         android:orientation="horizontal" >
 5 
 6         <TextView
 7             android:id="@+id/textView1"
 8             android:layout_width="wrap_content"
 9             android:layout_height="wrap_content"
10             android:text="编码" />
11 
12         <EditText
13             android:id="@+id/editText1"
14             android:layout_width="match_parent"
15             android:layout_height="wrap_content"
16             android:layout_weight="2"
17             android:ems="10" >
18 
19             <requestFocus />
20         </EditText>
21         
22 
23         <TextView
24             android:id="@+id/textView2"
25             android:layout_width="wrap_content"
26             android:layout_height="wrap_content"
27             android:text="名称" />
28         
29 
30 
31 
32 
33         <EditText
34             android:id="@+id/editText2"
35             android:layout_width="wrap_content"
36             android:layout_height="wrap_content"
37             android:layout_weight="1"
38             android:ems="10" >
39 
40             <requestFocus />
41         </EditText>
42       

43     </LinearLayout> 

 

这里比较重要的属性是:

 

android:layout_weight

该属性是设置比重的,但设置好像是反的,TextView就不要设置这个属性了,要不然显示会比较令人郁闷的. 

 

posted @ 2012-05-02 05:26 garfieldtom 阅读(7) 评论(0) 编辑

2012年1月13日

SQL Server查看表空间占用情况

 
查看数据库中各表的占用空间情况:
 
create table tablesize (name varchar(50),rows int,reserved varchar(50),
  data varchar(50),index_size varchar(50),unused varchar(50))
insert into tablesize (name,rows,reserved,
  data,index_size,unused) exec sp_msforeachTable @Command1="sp_spaceused '?'"
 
update tablesize set data=replace(data,'KB','')
 
select *,convert(int,data) as a from tablesize order by A desc
 
drop table tablesize

posted @ 2012-01-13 21:54 garfieldtom 阅读(126) 评论(0) 编辑

2011年12月31日

K9mail编译

今天试着编译一下K9Mail,找到官方的说明:

 

  1. Inside your working copy, make sure you have a directory named 'gen'
  2. From Eclipse, File > Import
  3. Under General, select 'Existing Projects into Workspace' and click Next
  4. Next to 'Select root directory', Browse to your K-9 working copy
  5. Click Finish
  6. In the Package Explorer, right click 'k9mail' and click 'Properties'
  7. Select 'Java Compiler'
  8. Check 'Enable project specific settings'
  9. Set the 'Compiler compliance level' to 1.6
  10. Click OK

 

在Android 2.3.1下调试通过。

 

附:

K9Mail:

http://code.google.com/p/k9mail/

https://github.com/k9mail/k-9/wiki/GitHub

posted @ 2011-12-31 15:37 garfieldtom 阅读(112) 评论(0) 编辑

2011年12月29日

文本文件导入数据库

如果有文本的数据库备份,怎么快速导入到数据库中?

当然,有很多方法,用各种语言写个小程序即可。

先不说要写个程序(是的,写这么个小程序用任何语言都不麻烦),导入效率就是一个大问题....

 

我使用SQL的Bulk insert :

BULK INSERT CSDN FROM 'D:\XX.txt'
WITH (
CODEPAGE='ANSI ',
DATAFILETYPE='char',
FIELDTERMINATOR=','  --如果文本用,号来分割字段内容的
)

 

我的电脑:Lenovo B470,SQL Server 2000,测试导入500W,用了不到4分钟。

posted @ 2011-12-29 15:11 garfieldtom 阅读(155) 评论(0) 编辑

2011年12月24日

pygame for android汉字显示问题

使用pygame在android上显示文字时,意外发现汉字不能正常显示,使用中文字体也不行,后来在网上请教了麦城_lookhere,他提供了一个方法,就是使用:

screen.blit(font.render(u"\u6d4b\u8bd5", True, (0, 0, 255)), (50, 50))

经测试,可以正常显示汉字了。

注意android平台上的python现在好像只有2.x版本。

非常感谢麦城_lookhere.

posted @ 2011-12-24 15:10 garfieldtom 阅读(105) 评论(0) 编辑

2011年12月22日

pygame for windows/linux/android版hello world(彻底跨界 :-) )

摘要: python的跨平台让人很舒服,好吧,这次我们跨的再直接一点,来次穿越吧:写一个可以在windows、linux、mac(?我没有)、android(手机、平板)上可以同时运行的程序!其他也没有什么好说的,直接上代码吧:#-------------------------------------------------------------------------------#Name:pygameforandroid版helloworld!#Purpose:##Author:garfield##Created:22-12-2011#Copyright:(c)garfield2011#Lic阅读全文

posted @ 2011-12-22 15:55 garfieldtom 阅读(182) 评论(2) 编辑

pygame版hello world

摘要: 没有什么好说的,直接上代码吧:#-------------------------------------------------------------------------------#Name:pygame版helloworld#Purpose:##Author:garfield##Created:22-12-2011#Copyright:(c)garfield2011#Licence:no#-------------------------------------------------------------------------------#!/usr/bin/envpytho阅读全文

posted @ 2011-12-22 11:57 garfieldtom 阅读(128) 评论(0) 编辑

2011年12月5日

Python,代码可以再简洁

摘要: 在网上看的,整理了一下:求10以内的偶数:首先这样写了:foriinrange(10):x=int(i%2)ifx==0:printi有人提出可以这样改进:foriinrange(10):ifi%2==0:printi再有人说,其实最简单是这样:[xforxinrange(10)ifx%2==0]代码可以简洁优美 :-)阅读全文

posted @ 2011-12-05 15:41 garfieldtom 阅读(281) 评论(2) 编辑

用Python写的一个简单的端口扫描程序

摘要: python做这个事情很轻松,如果省去不必要的参数输入部分,代码可以更简单 :-)直接上代码吧:#-------------------------------------------------------------------------------#Name:PortScan#Purpose:扫描目标主机的端口开放情况##Author:xxh##Created:05-12-2011#Copyright:(c)xxh2011#Licence:<yourlicence>#------------------------------------------------------阅读全文

posted @ 2011-12-05 15:31 garfieldtom 阅读(347) 评论(2) 编辑

2011年10月13日

一个Python练习

摘要: 两个练习:1.info = [1,2,3,4,5],用两种方法,把列表变成:info=[5,4,3,2,1]2.x = "abc1z" 用两种方法,把字符串x变成 x="abc2z"试着做了一下:#-------------------------------------------------------------------------------#Name:模块1#Purpose:##Author:Administrator##Created:13-10-2011#Copyright:(c)Administrator2011#Licence:&l阅读全文

posted @ 2011-10-13 14:54 garfieldtom 阅读(274) 评论(2) 编辑

仅列出标题  下一页

导航

统计

公告