Skip to content Skip to sidebar Skip to footer

Listview Row Updation

So In my app , I want there to be a news feed kind of thing . In this listview, I have an Custom Adapter which has a row layout like this. So as you can see , whenever the user hi

Solution 1:

So, though we already worked out the solution here in this chat, I am answering here for others to have a reference.

The problem here is that the view is not updating itself after the alpha values are being changed.

So, to update a view, we can use the invalidate() method, and the final code will look something like this :

    ....
    @Override
    public void onClick(View v) {
        if(gEvent.isWantsToReadMore()){                        //wants to read less
            Log.i("Entered the condition","Read less");
            customView.findViewById(R.id.geventEventPhoto).setAlpha(0.5f);
            // To make the view redraw itself, use invalidate()
            customView.findViewById(R.id.geventEventPhoto).invalidate();

        }
        else{                                       //wants to read more
            Log.i("Entered the condition","Read more");
            customView.findViewById(R.id.geventEventPhoto).setAlpha(1f);
            // To make the view redraw itself, use invalidate()
            customView.findViewById(R.id.geventEventPhoto).invalidate();
        }
    ...

Post a Comment for "Listview Row Updation"