@Subscribe public void onCreateTaskEvent(final RateTaskEvent event) { RecyclerView recyclerView = (RecyclerView) getView().findViewById(R.id.feed_recycler_view); } 

Signed for the event of the arrival of the custom event. In the fragment there is a RecycleView with custom views as elements. An event contains the string CUSTOM_ID = "example", how to find a specific view with CUSTOM_ID = "example" in RecycleView and change, for example, its color?

    1 answer 1

    In the onBindViewHolder adapter, you need to change the color depending on some value contained in the list of adapter data. Those. something like

     if(someListWithData.get(position).someValue == someConstant) { //тут один цвет назначается } else { //тут другой цвет назначается } 

    After changing the adapter, you have to change the value of the desired item in the adapter's data list when accepting an event and notify the adapter about the changes, forcing it to redraw items using the notifyDataSetChanged() or notifyItemChanged(int position) method.


    The main thing is not to try to directly reach the specific adapter view in an attempt to change it. You just have to change a certain condition according to which the adapter determines what and how to display it.

    • Yes, thanks, it was necessary - Alexander Borodin
    • @AlexanderBorodin, if the answer solves the problem posed in the question, then you can mark it as correct by clicking on the check mark to the left of the response body (but not earlier than 15 minutes after the question is published) - YuriySPb