imageview.setbackground 1

imageview.setbackground

 
         
            imageViewCategory.setBackground(getResources().getDrawable(R.drawable.layout_selected));
     
    

Here is what the above code is Doing:
1. We are getting the position of the item that was clicked.
2. We are getting the category name from the list of categories.
3. We are getting the image view of the item that was clicked.
4. We are setting the background of the image view to the selected background.
5. We are setting the background of the previously selected image view to the unselected background.

Now, we need to add the following code to the onCreate method of the MainActivity class:

Similar Posts