Thursday, September 6, 2012

Android: load image from server


photo = Constants.PHOTO_URL + (String) photoList.get("name");
if (photo instanceof String && photo.length() > 0) {
new ImageUtility.DownloadImage().execute(new ImageUtility.DownloadImageParameters(photo, new ImageUtility.DownloadImageListener() {
@Override
public void onDownloadCompleted(Bitmap downloadedImage) {
    if (downloadedImage != null) {
instance.bitmapThumbnail = ThumbnailUtils.extractThumbnail(downloadedImage, 100, 100);
instance.commentPhoto6.setImageBitmap(instance.bitmapThumbnail);
}
}
}));
}

Friday, July 27, 2012

在开始的时候隐藏Android软键盘

在AndroidManifest.xml的activity下添加 android:windowSoftInputMode="adjustPan"
比如:

        <activity
            android:name=".ProfileCommentsActivity"
            android:configChanges="orientation"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustPan" >
        activity>


GPS定位:需要在AndroidManifest.xml当中声明权限:android.permission.ACCESS_FINE_LOCATION
Network定位:需要在AndroidManifest.xml当中声明权限:android.permission.ACCESS_FINE_LOCATION (精确定位)

android.permission.ACCESS_COARSE_LOCATION (粗糙定位)

2获取LocationManager对象
3选择LocationProvider;
4绑定LocationListener对象;

Wednesday, July 25, 2012

Android listview

display on the position
listview.setSelection(position);

提示快捷键:alt+/

Layout attribute

grivity:在控件内容的位置情况。
layout_weight="1" 每个控件占用的比例

Monday, July 9, 2012

eclipse @override 报错 解决


我想这个问题肯定困扰了很多人,我也不例外。新公司用的东西多多少少会与我们以前公司的有所不同。所以这个问题也时常伴随在我们身边。
第一种解决方案:
@Override是JDK5 就已经有了,但有个小小的Bug,就是不支持对接口的实现,认为这不是Override
JDK6 修正了这个Bug,无论是对父类的方法覆盖还是对接口的实现都可以加上@Override

修改你的eclipse指定的编译器版本
在选项里的java compiler中指定版本至少在5.0以上

在myEclipse中改变编译器的方法:Project->Properties->Java Compiler->Configure Workspace Setting,在弹出的页面中可以进行设置。


第二种解决方案:(我使用这种方法,没有问题)
在JAVA 1.5和1.6中@override的用法是有些区别的,虽然改变了JRE但eclipse还是会报错。
解决办法:Windows->Preferences-->java->Compiler-->compiler compliance level设置成6.0就OK了.
注意:
但是在导入一个工程时,编译并打包到Tomcat后,发现出现java.lang.UnsupportedClassVersionError: Bad version number in .class file异常,检查了一下我的myEclipse,我发现我的eclipse的compiler的jdk版本 ,tomcat所用的jdk版本不一致,后来设置成一致就可以了 。看来果然是这个问题引起。
    那次在Linux上部署工程时也出现过因为版本不同引起的问题,那时我们用的IDE的编译器是JDK5.0,而那台Linux装的是JDK6.0,部署后发现很多功能都出错,看来有些东西还是注意一下啊。
    附,在myEclipse中改变编译器的方法:Project->Proper的ties->Java Compiler->Configure Workspace Setting,在弹出的页面中可以进行设置

 :
在android中有时也会出现如此问题,解决办法是Windows->Preferences-->java->Compiler 中 compiler compliance level 修改成1.6就可以了

其实这种方式与第二种差不多,殊途同归。第一种方式重点是设置这一个项目。而第二种重点设置所以项目。不过都可以用。

Thursday, July 5, 2012

Android RelativeLayout 的一些属性设置


下面介绍一下RelativeLayout用到的一些重要的属性:
第一类:属性值为true或falseandroid:layout_centerHrizontal                                           水平居中
android:layout_centerVertical                                            垂直居中
android:layout_centerInparent                                           相对于父元素完全居中
android:layout_alignParentBottom                                     贴紧父元素的下边缘
android:layout_alignParentLeft                                          贴紧父元素的左边缘
android:layout_alignParentRight                                        贴紧父元素的右边缘
android:layout_alignParentTop                                          贴紧父元素的上边缘
android:layout_alignWithParentIfMissing                            如果对应的兄弟元素找不到的话就以父元素做参照物
第二类:属性值必须为id的引用名“@id/id-name”
android:layout_below                          在某元素的下方
android:layout_above                          在某元素的的上方
android:layout_toLeftOf                       在某元素的左边
android:layout_toRightOf                     在某元素的右边
android:layout_alignTop                      本元素的上边缘和某元素的的上边缘对齐
android:layout_alignLeft                      本元素的左边缘和某元素的的左边缘对齐
android:layout_alignBottom                 本元素的下边缘和某元素的的下边缘对齐
android:layout_alignRight                    本元素的右边缘和某元素的的右边缘对齐
第三类:属性值为具体的像素值,如30dip,40pxandroid:layout_marginBottom              离某元素底边缘的距离
android:layout_marginLeft                   离某元素左边缘的距离
android:layout_marginRight                 离某元素右边缘的距离
android:layout_marginTop                   离某元素上边缘的距离



Thursday, April 12, 2012

Install Symfony2 on Windows, wamp or xampp



1. wamp or xampp is the best install on C: drive

2. setup php.ini

extension=php_intl.dll
extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
restart apache

3. if show on "http://localhost/symfony/web/config.php" need intl.dll and then copy 
icudt46.dll
icuin46.dll
icuio46.dll
icule46.dll
iculx46.dll
icutu46.dll
icuuc46.dll
from php folder to apache/bin folder

4. if show on "http://localhost/symfony/web/config.php" need APC then install APC
1) if on win7 download apc-igbinary-fastlz-snap20110301-5.3-ts-vc9-x86.zip from http://downloads.php.net/pierre/ and then uncompress to C:/xampp/php/ext
2) in php.ini 
add extension=php_apc.dll
change time zone: date.timezone=Pacific/Auckland

5. restart apache

Tuesday, March 13, 2012

Asp.Net C# MVC

1. In Controller if want to return a value:
return Content("You have been Cuisine");

2. In Global.asax.cs
setup router:

routes.MapRoute(
                    "Cuisine",
                    "cuisine/{name}",
                    new { controller = "Cuisine", action = "Search" }
                );
            routes.MapRoute(
                "Default", // Route name
               
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

3. In Controller: display RouteData.Values


ViewBag.Message = string.Format("{0}::{1} {2}",
                RouteData.Values["controller"],
                RouteData.Values["action"],
                RouteData.Values["id"]);

if url like http://localhost:22792/home/index/5 that will be displayed like home::index 5


4. 注释快捷键:

开发阶段:
Ctrl+K->C(/):注释一段代码;
Ctrl+K->U(/):取消注释一段代码;
(//=)加入cpp里类方法前面的标准注释;
(//-)加入开发人员个人信息,包括主机名和修改时间;

Thursday, February 23, 2012

How to install symfony2 and configure wamp or xampp on windows


一、安装xampp:这里不再详述。不过需要注意的是:你的xampp最好要安装在c盘。原因是:Symfony2使用过程中需要用到php命令,而系统默认php命令的路径在c:/xampp/php下。
二、配置php环境:
我的电脑->右键->属性->高级->环境变量->系统变量(第二个框框)
1.新建:变量名:PHP_HOME , 变量值: c:/XAMPP/php(你的php路径),确定
2.修改:双击path ,在变量值后面加上 ;%PHP_HOME%
确定保存
三、下载Symfony2:
Symfony2官网上下载Symfony2的zip文件.
将文件解压后放到c:/xampp/htdocs,这个路径也是要按照自己的路径来。
四、配置Symfony2的运行环境:
1、打开php.ini文件,一般会在C:/xampp/php目录下,将下列语句取消注释,或者添加:
extension=php_intl.dll
extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
重启apache。
注:你有可能会遇到intl.dll不存在的提示,你只需要将以下文件从PHP的文件夹复制到apache的bin目录里面即可:
  • icudt46.dll
  • icuin46.dll
  • icuio46.dll
  • icule46.dll
  • iculx46.dll
  • icutu46.dll
  • icuuc46.dll
2、在浏览器中输入网址http://localhost/Symfony/web/config.php,他会提示你还需要配置哪些东西,可能会有以下三个提示:
(1)安装APC:
在 http://downloads.php.net/pierre/ 网站下载正确版本的apc,win7一般下载apc-igbinary-fastlz-snap20110301-5.3-ts-vc9-x86.zip就可以,解压将php_apc.dll放在C:/xampp/php/ext下。
在php.ini添加extension=php_apc.dll。
(2)更改时区:date.timezone = Asia/Shanghai
(3)将short_open_tag设为On
(2)(3)都是更改php.ini。
重启apache。
刷新你http://localhost/Symfony/web/config.php页面,如果没有其他提示你就可以使用你的Symfony2了.

Tuesday, January 17, 2012

复习的方法


一、 复习点的确定(根据艾宾浩斯记忆曲线制定): 
1. 第一个记忆周期:5分钟 
2. 第二个记忆周期:30分钟 
3. 第三个记忆周期:12小时 
4. 第四个记忆周期:1天 
5. 第五个记忆周期:2天 
6. 第六个记忆周期:4天 
7. 第七个记忆周期:7天 
8. 第八个记忆周期:15天 

二、背诵方法: 
1. 初记单词时需要记忆的内容: 
a)单词外观,b) 单词的中文释义,c) 单词的记忆法 
2. 每个list的具体背诵过程(每个list按12页,每页10个单词计): 
a) 背完一页(大约5分钟),立即返回该页第一个单词开始复习(大约几十秒) 
b) 按上面方法背完1~6页(大约在30分钟),回到第1页开始复习(两三分钟) 
c) 按上面同样方法背完7~12页,一个list结束 
d) 相当于每个list被分为12个小的单元,每个小的单元自成一个复习系统;每6个小单元组成一个大单元,2个大单元各自成为一个复习系统。背一个list总共需要一小时左右的时间。

3. 复习过程: 
a) 复习方法:遮住中文释义,尽力回忆该单词的意思,几遍下来都记不住的单词可以做记号重点记忆。 
b) 复习一个list所需的时间为20分钟以内 
c) 当天的list最好在中午之前背完,大约12小时之后(最好睡觉前)复习当天所背的list 
d) 在其后的1,2,4,7,15天后分别复习当日所背的list 

4. 注意事项: 
a) 每天连续背诵2个list,并完成复习任务; 
b) 复习永远比记新词重要,要反复高频率的复习,复习,再复习; 
c) 一天都不能间断,坚持挺过这15天,之后每天都要花大约1小时复习; 

5. 时间表(左边序号表示第几天,*号之后表示复习内容) 
1. list1-2 *list1-2 
2. list3-4 *list1-2 list3-4 
3. list5-6 *list3-4 list5-6 
4. list7-8 *list1-2 list5-6 list7-8 
5. list9-10 *list3-4 list7-8 list9-10 
6. list11-12 *list5-6 list9-10 list11-12 
7. list13-14 *list7-8 list11-12 list13-14 
8. list15-16 *list1-2 list9-10 list13-14 list15-16 
9. list17-18 *list3-4 list11-12 list15-16 list17-18 
10. list19-20 *list5-6 list13-14 list17-18 list19-20 
11. list21-22 *list7-8 list15-16 list19-20 list21-22 
12. list23-24 *list9-10 list17-18 list21-22 list23-24 
13.*list11-12 list19-20 list23-24 
14.*list13-14 list21-22 
15.*list1-2 list15-16 list23-24 
16.*list3-4 list17-18 
17.*list5-6 list19-20 
18.*list7-8 list21-22 
19.*list9-10 list23-24 
20.*list11-12 
21.*list13-14 
22.*list15-16 
23.*list17-18 
24.*list19-20 
25.*list21-22 
26.*list23-24