当前位置: 编程技术>移动开发
本页文章导读:
▪菜单定做 菜单定制
对一个Android应用中的每一个屏幕,也就是说,对每一个Activity类,都会拥有一个默认菜单。在Activity类中,定义了几个与菜单有关的方法,供继承于Activity类的子类去重载,从而.........
▪ Ubuntu 11.04 装配极点五笔 for ibus Ubuntu 11.04 安装极点五笔 for ibus
Ubuntu 11.04 安装极点五笔 for ibus
具体操作步骤如下:
step1. 下载附件文件 vissible-ibus.tar.gz, 或从网络下载命令:
sudo wget http://www.xiit.cn/wp-content/uploads/2011/03/vissib.........
▪ java经过文件头内容判断文件类型 java通过文件头内容判断文件类型
/** * byte数组转换成16进制字符串 * @param src * @return */ public static String bytesToHexString(byte[] src){ StringBuilder stringBuilder = new StringBuilder(); .........
[1]菜单定做
来源: 互联网 发布时间: 2014-02-18
菜单定制
对一个Android应用中的每一个屏幕,也就是说,对每一个Activity类,都会拥有一个默认菜单。在Activity类中,定义了几个与菜单有关的方法,供继承于Activity类的子类去重载,从而定制我们自己的菜单。这几个方法为:
public boolean onCreateOptionsMenu(android.view.Menu menu);
public boolean onPrepareOptionsMenu(android.view.Menu menu);
public boolean onOptionsItemSelected(android.view.MenuItem item);
为了生成我们自己的菜单,Android为我们提供了两个时机点。当在Activity类实例启动时,我们可以通过重载onCreateOptionsMenu()来定制我们的菜单;另外,也可以在菜单每次被调用时,对菜单中的项重新生成,通过重载onPrepareOptionsMenu来实现。对于第二种方式,由于每次调用时都要重新生成,对于那些不经常变化的菜单,效率就会比较低。当选择某个菜单时,会调用onOptionsItemSelected方法。
对一个Android应用中的每一个屏幕,也就是说,对每一个Activity类,都会拥有一个默认菜单。在Activity类中,定义了几个与菜单有关的方法,供继承于Activity类的子类去重载,从而定制我们自己的菜单。这几个方法为:
public boolean onCreateOptionsMenu(android.view.Menu menu);
public boolean onPrepareOptionsMenu(android.view.Menu menu);
public boolean onOptionsItemSelected(android.view.MenuItem item);
为了生成我们自己的菜单,Android为我们提供了两个时机点。当在Activity类实例启动时,我们可以通过重载onCreateOptionsMenu()来定制我们的菜单;另外,也可以在菜单每次被调用时,对菜单中的项重新生成,通过重载onPrepareOptionsMenu来实现。对于第二种方式,由于每次调用时都要重新生成,对于那些不经常变化的菜单,效率就会比较低。当选择某个菜单时,会调用onOptionsItemSelected方法。
[2] Ubuntu 11.04 装配极点五笔 for ibus
来源: 互联网 发布时间: 2014-02-18
Ubuntu 11.04 安装极点五笔 for ibus
Ubuntu 11.04 安装极点五笔 for ibus
具体操作步骤如下:
step1. 下载附件文件 vissible-ibus.tar.gz, 或从网络下载
命令:
sudo wget http://www.xiit.cn/wp-content/uploads/2011/03/vissible-ibus.tar.gz
step2. 解压文件
命令:
tar -zxvf vissible-ibus.tar.gz
step3. 执行命令
cd vissible-ibus sudo cp vissible.db /usr/share/ibus-table/tables sudo cp vissible.gif /usr/share/ibus-table/icons
step4. 操作完成后, 重启 ibus 或 注销再登录, 然后在 ibus 里添加极点五笔即可.
具体步骤: 点击任务栏中的键盘小图标, 在下拉菜单选 "Restart(重启)" 重启ibus输入法, 然后再点一下键盘小图标并在下拉菜单中选"Preference(首选项)", 然后在弹出的窗口中点击 "Input Method(输入法)" 选项卡, 接着点 "Select an input method(选择输入法)" > "Chinese(汉语)", 然后点 "添加" 极点五笔, OK!
注意: 如原来已经用过, 请把~/.ibus/tables/vissible-user.db删除, 或者也可以把 vissible.db改成别的*.db.
[3] java经过文件头内容判断文件类型
来源: 互联网 发布时间: 2014-02-18
java通过文件头内容判断文件类型
/**
* byte数组转换成16进制字符串
* @param src
* @return
*/
public static String bytesToHexString(byte[] src){
StringBuilder stringBuilder = new StringBuilder();
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < src.length; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
}
return stringBuilder.toString();
}
/**
* 根据文件流读取图片文件真实类型
* @param is
* @return
*/
public static String getTypeByStream(FileInputStream is){
byte[] b = new byte[4];
try {
is.read(b, 0, b.length);
} catch (IOException e) {
e.printStackTrace();
}
String type = bytesToHexString(b).toUpperCase();
if(type.contains("FFD8FF")){
return "jpg";
}else if(type.contains("89504E47")){
return "png";
}else if(type.contains("47494638")){
return "gif";
}else if(type.contains("49492A00")){
return "tif";
}else if(type.contains("424D")){
return "bmp";
}
return type;
}
public static void main(String[] args) throws Exception {
// String src = "D:/workspace//8129.jpg";
// String src = "D:/workspace//temp/1.gif";
String src = "D:/workspace//temp/2.bmp";
FileInputStream is = new FileInputStream(src);
// byte[] b = new byte[4];
// is.read(b, 0, b.length);
// System.out.println(bytesToHexString(b));
String type = getTypeByStream(is);
System.out.println(type);
/*
* JPEG (jpg),文件头:FFD8FF
PNG (png),文件头:89504E47
GIF (gif),文件头:47494638
TIFF (tif),文件头:49492A00
Windows Bitmap (bmp),文件头:424D
*/
}
==================================
用文件头判断。直接读取文件的前几个字节。
常用文件的文件头如下:
JPEG (jpg),文件头:FFD8FF
PNG (png),文件头:89504E47
GIF (gif),文件头:47494638
TIFF (tif),文件头:49492A00
Windows Bitmap (bmp),文件头:424D
CAD (dwg),文件头:41433130
Adobe Photoshop (psd),文件头:38425053
Rich Text Format (rtf),文件头:7B5C727466
XML (xml),文件头:3C3F786D6C
HTML (html),文件头:68746D6C3E
Email [thorough only] (eml),文件头:44656C69766572792D646174653A
Outlook Express (dbx),文件头:CFAD12FEC5FD746F
Outlook (pst),文件头:2142444E
MS Word/Excel (xls.or.doc),文件头:D0CF11E0
MS Access (mdb),文件头:5374616E64617264204A
WordPerfect (wpd),文件头:FF575043
Postscript. (eps.or.ps),文件头:252150532D41646F6265
Adobe Acrobat (pdf),文件头:255044462D312E
Quicken (qdf),文件头:AC9EBD8F
Windows Password (pwl),文件头:E3828596
ZIP Archive (zip),文件头:504B0304
RAR Archive (rar),文件头:52617221
Wave (wav),文件头:57415645
AVI (avi),文件头:41564920
Real Audio (ram),文件头:2E7261FD
Real Media (rm),文件头:2E524D46
MPEG (mpg),文件头:000001BA
MPEG (mpg),文件头:000001B3
Quicktime (mov),文件头:6D6F6F76
Windows Media (asf),文件头:3026B2758E66CF11
MIDI (mid),文件头:4D546864
GRAPHICS FILESAdobe Photoshop File (.psd)
00000000 38 42 50 53 00 01 00 00 00 00 00 00 00 04 00 00 |8BPS............|
00000010 0b 71 00 00 10 dd 00 08 00 03 00 00 00 00 00 00 |.q...?..........|
00000020 6f c4 38 42 49 4d 04 04 00 00 00 00 00 07 1c 02 |o?8BIM..........|
JPEG image (.jpg)
00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 |????..JFIF.....H|
00000010 00 48 00 00 ff db 00 43 00 06 04 05 06 05 04 06 |.H..??.C........|
00000020 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e |................|
PNG image (.png)
00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 |.PNG........IHDR|
00000010 00 00 03 20 00 00 02 58 08 06 00 00 00 9a 76 82 |... ...X......v.|
00000020 70 00 00 0c d9 69 43 43 50 69 63 63 00 00 78 da |p...?iCCPicc..x?|
GIF image (.gif)
00000000 47 49 46 38 39 61 10 00 10 00 b3 0d 00 3f 3f 3f |GIF89a....?..???|
00000010 bf bf bf 2a 2a 2a 55 55 55 7f 7f 7f 15 15 15 40 |???***UUU......@|
00000020 40 40 60 60 60 c0 c0 c0 2f 2f 2f 90 90 90 ff ff |@@```???///...??|
Adobe Illustrator File (.ai)
00000000 25 50 44 46 2d 31 2e 34 0d 25 e2 e3 cf d3 0d 0a |%PDF-1.4.%????..|
00000010 31 20 30 20 6f 62 6a 3c 3c 2f 50 61 67 65 73 20 |1 0 obj<</Pages |
00000020 32 20 30 20 52 2f 54 79 70 65 2f 43 61 74 61 6c |2 0 R/Type/Catal|MUSIC FILESMP3 Music Track (.mp3)
00000000 49 44 33 03 00 00 00 00 00 6f 54 49 54 32 00 00 |ID3......oTIT2..|
00000010 00 0e 00 00 00 54 68 65 20 4f 74 68 65 72 20 4d |.....The Other M|
00000020 61 6e 54 52 43 4b 00 00 00 02 00 00 00 33 54 50 |anTRCK.......3TP|
WAV file (.wav)
00000000 52 49 46 46 62 b7 01 00 57 41 56 45 66 6d 74 20 |RIFFb?..WAVEfmt|
00000010 10 00 00 00 01 00 01 00 44 ac 00 00 88 58 01 00 |........D?...X..|
00000020 02 00 10 00 64 61 74 61 3e b7 01 00 57 01 bd 01 |....data>?..W.?.|
AIFF file (.aif)
00000000 46 4f 52 4d 00 2a ef cc 41 49 46 46 43 4f 4d 54 |FORM.*??AIFFCOMT|
00000010 00 00 01 c2 00 01 00 00 00 00 00 00 00 12 43 72 |...?..........Cr|
00000020 65 61 74 6f 72 3a 20 4c 6f 67 69 63 20 50 72 6f |eator: Logic Pro|TEXT FILESText file (often .txt, but not always)
00000000 48 69 20 65 76 65 72 79 6f 6e 65 2c 0a 0a 48 65 |Hi everyone,..He|
00000010 72 65 20 61 72 65 20 73 6f 6d 65 20 63 68 61 6e |re are some chan|
00000020 67 65 73 20 74 68 61 74 20 77 69 6c 6c 20 68 61 |ges that will ha|
Microsoft Word/Office (.doc, .xls)
00000000d0 cf 11 e0 a1 b1 1a e100 00 00 00 00 00 00 00 |??.....?........|
00000010 00 00 00 00 00 00 00 00 3e 00 03 00 fe ff 09 00 |........>...??..|
00000020 06 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |................|
Adobe PDF (.pdf) - Very similar to Adobe Illustrator and other Postscript. formats
00000000 25 50 44 46 2d 31 2e 34 0d 25 e2 e3 cf d3 0d 0a |%PDF-1.4.%????..|
00000010 36 20 30 20 6f 62 6a 20 3c 3c 2f 4c 69 6e 65 61 |6 0 obj <</Linea|
00000020 72 69 7a 65 64 20 31 2f 4c 20 34 34 30 36 38 2f |rized 1/L 44068/|ANIMATION & VIDEOFlash movie (.swf)
00000000 43 57 53 08 ac 43 00 00 78 9c ed 7a 77 58 93 c9 |CWS.?C..x.?zwX.?|
00000010 d6 f8 49 25 f4 80 94 50 0d 45 4a 00 e9 45 b0 04 |??I%?..P.EJ.?E?.|
00000020 44 44 45 e9 55 d0 80 44 01 11 10 11 01 75 0d bd |DDE?U?.D.....u.?|
Quicktime Movie (.mov)
00000000 00 00 00 20 66 74 79 70 71 74 20 20 20 05 03 00 |... ftypqt ...|
00000010 71 74 20 20 00 00 00 00 00 00 00 00 00 00 00 00 |qt............|
00000020 00 00 03 55 6d 6f 6f 76 00 00 00 6c 6d 76 68 64 |...Umoov...lmvhd|
/**
* byte数组转换成16进制字符串
* @param src
* @return
*/
public static String bytesToHexString(byte[] src){
StringBuilder stringBuilder = new StringBuilder();
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < src.length; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
}
return stringBuilder.toString();
}
/**
* 根据文件流读取图片文件真实类型
* @param is
* @return
*/
public static String getTypeByStream(FileInputStream is){
byte[] b = new byte[4];
try {
is.read(b, 0, b.length);
} catch (IOException e) {
e.printStackTrace();
}
String type = bytesToHexString(b).toUpperCase();
if(type.contains("FFD8FF")){
return "jpg";
}else if(type.contains("89504E47")){
return "png";
}else if(type.contains("47494638")){
return "gif";
}else if(type.contains("49492A00")){
return "tif";
}else if(type.contains("424D")){
return "bmp";
}
return type;
}
public static void main(String[] args) throws Exception {
// String src = "D:/workspace//8129.jpg";
// String src = "D:/workspace//temp/1.gif";
String src = "D:/workspace//temp/2.bmp";
FileInputStream is = new FileInputStream(src);
// byte[] b = new byte[4];
// is.read(b, 0, b.length);
// System.out.println(bytesToHexString(b));
String type = getTypeByStream(is);
System.out.println(type);
/*
* JPEG (jpg),文件头:FFD8FF
PNG (png),文件头:89504E47
GIF (gif),文件头:47494638
TIFF (tif),文件头:49492A00
Windows Bitmap (bmp),文件头:424D
*/
}
==================================
用文件头判断。直接读取文件的前几个字节。
常用文件的文件头如下:
JPEG (jpg),文件头:FFD8FF
PNG (png),文件头:89504E47
GIF (gif),文件头:47494638
TIFF (tif),文件头:49492A00
Windows Bitmap (bmp),文件头:424D
CAD (dwg),文件头:41433130
Adobe Photoshop (psd),文件头:38425053
Rich Text Format (rtf),文件头:7B5C727466
XML (xml),文件头:3C3F786D6C
HTML (html),文件头:68746D6C3E
Email [thorough only] (eml),文件头:44656C69766572792D646174653A
Outlook Express (dbx),文件头:CFAD12FEC5FD746F
Outlook (pst),文件头:2142444E
MS Word/Excel (xls.or.doc),文件头:D0CF11E0
MS Access (mdb),文件头:5374616E64617264204A
WordPerfect (wpd),文件头:FF575043
Postscript. (eps.or.ps),文件头:252150532D41646F6265
Adobe Acrobat (pdf),文件头:255044462D312E
Quicken (qdf),文件头:AC9EBD8F
Windows Password (pwl),文件头:E3828596
ZIP Archive (zip),文件头:504B0304
RAR Archive (rar),文件头:52617221
Wave (wav),文件头:57415645
AVI (avi),文件头:41564920
Real Audio (ram),文件头:2E7261FD
Real Media (rm),文件头:2E524D46
MPEG (mpg),文件头:000001BA
MPEG (mpg),文件头:000001B3
Quicktime (mov),文件头:6D6F6F76
Windows Media (asf),文件头:3026B2758E66CF11
MIDI (mid),文件头:4D546864
GRAPHICS FILESAdobe Photoshop File (.psd)
00000000 38 42 50 53 00 01 00 00 00 00 00 00 00 04 00 00 |8BPS............|
00000010 0b 71 00 00 10 dd 00 08 00 03 00 00 00 00 00 00 |.q...?..........|
00000020 6f c4 38 42 49 4d 04 04 00 00 00 00 00 07 1c 02 |o?8BIM..........|
JPEG image (.jpg)
00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 |????..JFIF.....H|
00000010 00 48 00 00 ff db 00 43 00 06 04 05 06 05 04 06 |.H..??.C........|
00000020 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e |................|
PNG image (.png)
00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 |.PNG........IHDR|
00000010 00 00 03 20 00 00 02 58 08 06 00 00 00 9a 76 82 |... ...X......v.|
00000020 70 00 00 0c d9 69 43 43 50 69 63 63 00 00 78 da |p...?iCCPicc..x?|
GIF image (.gif)
00000000 47 49 46 38 39 61 10 00 10 00 b3 0d 00 3f 3f 3f |GIF89a....?..???|
00000010 bf bf bf 2a 2a 2a 55 55 55 7f 7f 7f 15 15 15 40 |???***UUU......@|
00000020 40 40 60 60 60 c0 c0 c0 2f 2f 2f 90 90 90 ff ff |@@```???///...??|
Adobe Illustrator File (.ai)
00000000 25 50 44 46 2d 31 2e 34 0d 25 e2 e3 cf d3 0d 0a |%PDF-1.4.%????..|
00000010 31 20 30 20 6f 62 6a 3c 3c 2f 50 61 67 65 73 20 |1 0 obj<</Pages |
00000020 32 20 30 20 52 2f 54 79 70 65 2f 43 61 74 61 6c |2 0 R/Type/Catal|MUSIC FILESMP3 Music Track (.mp3)
00000000 49 44 33 03 00 00 00 00 00 6f 54 49 54 32 00 00 |ID3......oTIT2..|
00000010 00 0e 00 00 00 54 68 65 20 4f 74 68 65 72 20 4d |.....The Other M|
00000020 61 6e 54 52 43 4b 00 00 00 02 00 00 00 33 54 50 |anTRCK.......3TP|
WAV file (.wav)
00000000 52 49 46 46 62 b7 01 00 57 41 56 45 66 6d 74 20 |RIFFb?..WAVEfmt|
00000010 10 00 00 00 01 00 01 00 44 ac 00 00 88 58 01 00 |........D?...X..|
00000020 02 00 10 00 64 61 74 61 3e b7 01 00 57 01 bd 01 |....data>?..W.?.|
AIFF file (.aif)
00000000 46 4f 52 4d 00 2a ef cc 41 49 46 46 43 4f 4d 54 |FORM.*??AIFFCOMT|
00000010 00 00 01 c2 00 01 00 00 00 00 00 00 00 12 43 72 |...?..........Cr|
00000020 65 61 74 6f 72 3a 20 4c 6f 67 69 63 20 50 72 6f |eator: Logic Pro|TEXT FILESText file (often .txt, but not always)
00000000 48 69 20 65 76 65 72 79 6f 6e 65 2c 0a 0a 48 65 |Hi everyone,..He|
00000010 72 65 20 61 72 65 20 73 6f 6d 65 20 63 68 61 6e |re are some chan|
00000020 67 65 73 20 74 68 61 74 20 77 69 6c 6c 20 68 61 |ges that will ha|
Microsoft Word/Office (.doc, .xls)
00000000d0 cf 11 e0 a1 b1 1a e100 00 00 00 00 00 00 00 |??.....?........|
00000010 00 00 00 00 00 00 00 00 3e 00 03 00 fe ff 09 00 |........>...??..|
00000020 06 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |................|
Adobe PDF (.pdf) - Very similar to Adobe Illustrator and other Postscript. formats
00000000 25 50 44 46 2d 31 2e 34 0d 25 e2 e3 cf d3 0d 0a |%PDF-1.4.%????..|
00000010 36 20 30 20 6f 62 6a 20 3c 3c 2f 4c 69 6e 65 61 |6 0 obj <</Linea|
00000020 72 69 7a 65 64 20 31 2f 4c 20 34 34 30 36 38 2f |rized 1/L 44068/|ANIMATION & VIDEOFlash movie (.swf)
00000000 43 57 53 08 ac 43 00 00 78 9c ed 7a 77 58 93 c9 |CWS.?C..x.?zwX.?|
00000010 d6 f8 49 25 f4 80 94 50 0d 45 4a 00 e9 45 b0 04 |??I%?..P.EJ.?E?.|
00000020 44 44 45 e9 55 d0 80 44 01 11 10 11 01 75 0d bd |DDE?U?.D.....u.?|
Quicktime Movie (.mov)
00000000 00 00 00 20 66 74 79 70 71 74 20 20 20 05 03 00 |... ftypqt ...|
00000010 71 74 20 20 00 00 00 00 00 00 00 00 00 00 00 00 |qt............|
00000020 00 00 03 55 6d 6f 6f 76 00 00 00 6c 6d 76 68 64 |...Umoov...lmvhd|
最新技术文章: