You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.
When a row in the FAQArrayAdapter is selected, the TextView "faqDesc" becomes visible, showing the description of that item. But, when you scroll up or down the ArrayAdapter, the row gets reset, thus making the "faqDesc" TextView invisible again.
Steps to reproduce:
Go to any activity that uses the FAQArrayAdapter. For example, go to SAFETY TOOLS -> UNWANTED ATTENTION.
Click on any row. This will make the description visible.
Scroll down till the row you selected is not seen on the screen.
Scroll back up to the row you had selected before. The description is now invisible.
The expected outcome should be that each row should retain its state even on scrolling. Rows that were selected and expanded to show their description should remain expanded when the user scrolls and then comes back to the same row.
I have attached 2 videos. One shows the bug and the other shows what it looks like after the fix.
The bug:
The fix: @sandarumk I would like to work on this. Can I send a PR fixing this?
The text was updated successfully, but these errors were encountered:
@sandarumk My proposed solution is to store the state (whether the description is visible or not) of each item in the array adapter in an array faqVisibilities (just like faqTitles and faqDescriptions) and in the getView() function of FAQArrayAdapter.java, along with setting the title and the description, we can set the visibility of the description also based on the value of faqVisiblities at that position. I have already written this code and the video of this is attached with the question.
Hey @Pooja-Mahadev-Soundalgekar, your solution looks good but can be further optimised. It would be better to store just the expanded textviews in the Arraylist instead of storing state of every textview since this array will be called many times. There is no need to store the already collapsed Textview.
Check if textview to be expanded is in Arraylist, if yes do nothing, if no add it.
Check if textview to be collapsed is in Arraylist, if yes remove it from arraylist, if no do nothing.
The solution I propose is to use a HashSet<Integer> expandedPositions. If a position is present in this set, it means that it has been expanded by the user. In the getView() function, we check if the current position is present in this HashSet and change the view depending on this. When the user clicks on an item in the array adapter, depending on whether the row is expanded or collapsed, we insert or delete that position from this HashSet.
When a row in the FAQArrayAdapter is selected, the TextView "faqDesc" becomes visible, showing the description of that item. But, when you scroll up or down the ArrayAdapter, the row gets reset, thus making the "faqDesc" TextView invisible again.
Steps to reproduce:
The expected outcome should be that each row should retain its state even on scrolling. Rows that were selected and expanded to show their description should remain expanded when the user scrolls and then comes back to the same row.
I have attached 2 videos. One shows the bug and the other shows what it looks like after the fix.
The bug:
The fix:
@sandarumk I would like to work on this. Can I send a PR fixing this?
The text was updated successfully, but these errors were encountered: