我在一个gridView上移动一个ImageView,当触发setOnItemSelectedListener方法时,把这个ImageView移动过去,
每次移动都有1s左右的延迟(应该不是代码的执行导致的延迟),就是先选择了一个item,过1s左右的时间,图片才会移动过来,
但当我连续移动两次时,很连贯,没有出延迟的情况,请大家帮忙看看,是什么原因啊?先谢了!
gridview.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?>arg0, View arg1, int arg2, long arg3){
System.out.println("onItemSelected:"+arg1);
if(arg1==null)
{
gridview.setSelection(0);
return;
}
select_vod_item = arg2;
int[] location=new int[2];
arg1.getLocationInWindow(location);
am = new TranslateAnimation (locationx,location[0]-372,locationy,location[1]-25);
am. setDuration (1000);
scrollImage.setAnimation (am);
am.setInterpolator(new DecelerateInterpolator());
am.setFillAfter(true);
// 动画开始
am.start();
locationx = location[0]-372;
locationy = location[1]-25;
}
[code="java"]因为移动距离长 同样的动画事件 那么
速度快啊 你就感觉不到延迟了
前几天看到一个问题说 再oncreate下启动动画 存在动画绑定的时间·
我想你点击事件 也会存在这个问题吧
[/code]
[code="java"] am. setDuration (1000);
因为你设置了 动画的执行时间 是1s啊。。。
你把这个时间再设置短点 看看·
[/code]
什么意思?
先移动一个 OK
接着移动 出现延迟???
[code="java"]gridview.setOnItemSelectedListener()
触发这个事件 启动动画 是不是有一个 绑定动画View的时间
[/code]
[code="java"]android内部机制的问题把
你设置下这个setStartOffset(0) 试试[/code]