I am trying to use BaseAdapter to display an item in a ListView. I am trying to make the code below in BaseAdapter.
@Override public View getView(final int position, View convertView, ViewGroup parent) { //... convertView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: v.setBackgroundResource(R.drawable.ic_corner_four_click); break; case MotionEvent.ACTION_UP: v.setBackgroundResource(R.drawable.ic_corner_four); break; } return false; } }); }
While the item will be affected, it changes the background to ic_corner_four_click. But until you release your finger or move on to another item, it has not changed to ic_corner_four. How to change it?
source share