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对象;
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" 每个控件占用的比例
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,在弹出的页面中可以进行设置。
而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,在弹出的页面中可以进行设置
那次在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. 注释快捷键:
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里类方法前面的标准注释;
(//-)加入开发人员个人信息,包括主机名和修改时间;
Subscribe to:
Posts (Atom)