我有我的應用程序中的自定義列表視圖。每個列表項左側有一個圖標,右側有一些文本。 我希望在點擊圖標時顯示一些動畫。我已經使用了ontouch監聽器,在MotionEvent.ACTION_DOWN事件和其他一些動作發生在MotionEvent.ACTION_UP事件上時,動畫開始於此處。Last ListItem總是收到ontouch事件
問題是,當我在列表視圖中單擊特定項目時,該圖標會爲該特定項目以及列表視圖中的最後一項獲取動畫..每次..不確定問題可能是什麼。請幫助。
代碼的相關部分粘貼如下:
public class Accounts implements OnItemClickListener, OnClickListener, AnimationListener{
Animation animation1;
ImageButton folderBTN;
//oncreate method
animation1 = AnimationUtils.loadAnimation(this, R.anim.to_middle);
animation1.setAnimationListener(this);
//Adapter getview method
..
.
.
.
getView(){
folderBTN.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
folderBTN.clearAnimation();
folderBTN.setAnimation(animation1);
folderBTN.startAnimation(animation1);
isIconShowing=true;
} else if (event.getAction() == MotionEvent.ACTION_UP) {
FolderList.actionHandleAccount(Accounts.this,
(Account) account);
}
return false;
}
}
}
謝謝..我會嘗試這..但我想知道爲什麼這是發生在列表視圖中的最後一個項目.. – ambit