0

I have a framelayout with recyclerview and button:

<FrameLayout
        android:id="@+id/foreground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/SG_White"
        android:clickable="true"
        android:focusable="true">

        //BUTTON CODE

        // RECYCLERVIEW CODE
</FrameLayout>

The button is hidden by default, but for some action (eg another button press), i want the button in framelayout to show over a specific index of the recyclerview.

say i want button to show on index 2 of recyclerview, then whatever is in index 2 of recyclerview will hide and the button will show on top of it. the end state will be:

-----
ITEM 0
-----
ITEM 1
-----
BUTTON (HIDING ITEM 2)
-----
ITEM 3
-----

currently the code always shows the button on top of the first item in recyclerview. how to get it over an arbitrary index eg 3 or 4??

afgfdg
  • 21
  • 3
  • You are to have 2 `ViewHolders`. One is `item` and another is `button`. Then add both items to an adapter. – CoolMind May 04 '21 at 22:46
  • Not entirely sure what you mean. Do you mean instead of adding items to the recyclerview, I need to create a custom class that cotains both item and a button? – afgfdg May 04 '21 at 22:48
  • No, he meant that you inflate different view for your items in your adapter depending on your logic. As seen [here](https://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type) – javdromero May 05 '21 at 00:23
  • @javdromero, agree. – CoolMind May 05 '21 at 08:30

0 Answers0