Search code examples
androiduser-interfacecustom-adapter

Show slight tint overlay on Custom Adapter On Long Click


I have a customer adapter which is used to displays a list of items. I want to show a light white colored tint over the whole custom adapter whenever the user long clicks an item to give a sense of selection (I also plan to place an image over it later on, like a heart or thumbs icon to represent that the item has been liked but that's a different story).

But the problem is how to do it, I can't figure it out and also couldn't find anything on Google.

What would be a simple way for doing it?


Solution

  • Why you aren't trying to change the value of alpha of your adapterview? Just like-

    public View getView(final int position, View convertView, ViewGroup parent) 
    { .
      .
      .
    
      convertView.setAlpha(0.4);   //change the value as per your need
    }
    

    Even if you don't want to use this feel free to make a state_selected item in your selector and use on your adapter onItemLongClick.

    As per op's need posting this tutorial link, it describes the way to implement an Instagram-like Heart Animation: http://ratiksharma.com/blog/implementing-an-instagram-like-heart-animation-on-android/