问题如下图:

第一次点击时,动画效果没错。但第二次点击时,两个白色的item都动了。貌似是上次的动画又播了一遍,求指导决方法。
重写了baseAdapter,class MusicListAdapter extends BaseAdapter。
getView如下,仅设置了选中字体和非选中字体静态效果。

第一次点击时,动画效果没错。但第二次点击时,两个白色的item都动了。貌似是上次的动画又播了一遍,求指导决方法。
重写了baseAdapter,class MusicListAdapter extends BaseAdapter。
getView如下,仅设置了选中字体和非选中字体静态效果。
class MusicListAdapter extends BaseAdapter{
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int arg0) {
return list.get(arg0);
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
if (arg1 == null) {
arg1 = getLayoutInflater().inflate(R.layout.list_item,
null);
}
TextView tv_music_name = (TextView) arg1
.findViewById(R.id.textView1_music_name);
tv_music_name.setTextColor(Color.WHITE);
tv_music_name.setText(list.get(arg0).substring(18).replace(".mp3", " ").replace("_", "-"));
if(arg0==FIXMUSICINDEX){//位置FIXMUSICINDEX固定被选中
tv_music_name.setAlpha(1);
tv_music_name.setTextColor(Color.rgb(30,144,255));
tv_music_name.setTextSize(25);
tv_music_name.setBackgroundResource(R.drawable.colorchange);
tv_music_name.setFocusable(true);//实现focus在列表
tv_music_name.requestFocus();
}
else if(arg0>=0&&arg0<getCount()){
tv_music_name.setTextColor(Color.argb(150,255,255,255));
tv_music_name.setShadowLayer(3F,1F,1F,Color.argb(255, 200, 200, 200));
tv_music_name.setTextSize(19);
tv_music_name.setBackgroundResource(R.drawable.black);
tv_music_name.getBackground().setAlpha(0);
}
if(arg0==getCount())
clickflag=0;
return arg1;
}
listView的点击监听事件如下,写在oncreate()里,在这里定义了点击项动画:
listView.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
orienIndex=arg2-FIXMUSICINDEX;
updatemusiclist();
if(orienIndex>0)
arg0.startAnimation(textup);
else if(orienIndex<0)
arg0.startAnimation(textdown);
clickflag=1;
listView.clearAnimation();
listView.getChildAt(currIndex).startAnimation(tbig);
if(clickflag==1){
listView.getChildAt(recordpreviousindex).startAnimation(tsmall);
}
}
});
其中recordpreviousindex记录上次位置为4的item现在的位置。
这个listener在每次点击的时候执行了几次啊,为神马会在一次点击时有这么多动画?
解决方案:50分