ITeye博客

2012 年文章归档

共 7 篇文章

ViewPager 嵌套 左右滑动问题

在viewpager中放了一个HorizontalScrollVIew ,但是发现HorizontalScrollVIew 无法左右滚动Item,特郁闷。 后来在stackoverflow上面看到一个帖子。于是就仿照,果然成功了。下面是原来的帖子代码 public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_MOVE: pager.requestDisallowInterceptTouchEvent(true); break; case Mo…

2012-11-26 16:17

Hibernate IllegalArgumentException

今天用hibernate时候出现,IllegalArgumentException occurred calling getter of com.yu.model.Customer.id 根本原因是类型不匹配 在一对多的多的一方配置错误 <many-to-one name="customer" column="customer_id" class="com.yu.model.Customer"></many-to-one> 错误将customer配置成customerId, customerId是int类型,所以导致爆出参数异常 <many-to-one name="customerId" …

2012-11-25 20:06

ListView 下拉刷新

看了ListView的下拉刷新,原理是动态调整 Listview的第一行的paddingTop值,然后就能实现ListView的下拉刷新。 有下面几个ListView常用的方法 getFirstVisiblePosition() 取得界面上第一个显示的位置 getLastVisiblePosition() 取得界面上最后一个显示的位置 setSelection(int position) 设置当前选中的位置,List会自动调至该位置 sdetVerticalScrollBarEnable(true) 设置scrollbar不能往下拉 getMeasuredHeight() 达到测量的长度,要…

2012-11-23 15:40

Android Gesture

转载 http://www.cnblogs.com/transmuse/archive/2010/12/02/1894833.html 大牛研究的好透彻 GestureDetector和SimpleOnGestureListener的使用教程 1. 当用户触摸屏幕的时候,会产生许多手势,例如down,up,scroll,filing等等,我们知道View类有个View.OnTouchListener内部接口,通过重写他的 onTouch ( View v, MotionEvent event)方法,我们可以处理一些touch事件,但是这个方法太过简单,如果需要处理一些复杂的手势,用这个接口就…

2012-11-22 13:46

ant 安装Android应用

1.最近因为项目需要在ant环境下安装打包好的apk文件,代码如下 <?xml version="1.0" encoding="UTF-8"?> <project name="installpackage" default="install"> <target name="uninstall"> <exec executable="cmd"> <arg value="/c"/> <arg value="adb uninstall com.phonemenu" /> </exec> </target> <target name="install" depends="uninstall"> <e…

2012-11-21 14:08 · Ant · Android

Android 裁剪图片

1.android的图片剪裁 Intent intent = new Intent("com.android.camera.action.CROP"); //要裁剪的图片 File file = new File(Environment.getExternalStorageDirectory(), "/Camera.png"); Uri uri = Uri.fromFile(file); intent.setDataAndType(uri, "image/*"); //指定剪裁的比例,若不设定,则可以任意宽度和高度 // intent.putExtra("aspectX", 1); // i…

2012-11-20 15:23 · Android

android 图片指定大小并保存

图片保存至SD卡上,注意,只能缩小,不能将图片放大,最多只能到图片的原始大小 FileOutputStream outputStream = null; mBitmap = BitmapFactory.decodeFile(path, options); Log.e(TAG, "options.outHeight:" + options.outHeight + " :mScreenWidth:" + mScreenWidth); if (options.outHeight < mScreenWidth / 2) { Log.e(TAG, "createBitMap invoke!"); op…

2012-11-20 13:53