[Solved] How to find which item in the list was clicked on (how do I find the position of an element in a list/array)

So basically I am on one screen which has a list with post titles, and I want to click on an element in the list which will redirect me to a new page. That new page should have the Post title and Post description corresponding to the item I clicked on which are all stored on Firebase. My question is how to find which item was clicked on?

For example… Lets say a list had titles of:

Post1
Post2
Post3

and then I click on Post 2. The description of Post 2 is “this is post 2”
I want the new screen to show the Title as Post 2 and description as “this is post 2”.

Same for Post3 or Post1 if i click on that

If you are using a list viewer, the “item click” event block for the list viewer has two green blocks: item and index. The item is the text of the item the user clicked. The index is the row number of the item the user clicked.

You can use the index value to get the other data from Firebase.

2 Likes

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.