I am facing problem when trying to implement ViewPager. I have a set of adaptive questions and depending on what the user answers for the first question, the second question will be asked. Now ViewPager requires atleast 2 Views and I have to decide at runtime what data will be loaded into the View. What would be the best approach to implement this. I tried to keep an arraylist and load the data into it when the user answers the first question. But the changes are not getting reflected and the application crashes giving a nullpointerException. Also, since the questions are added dynamically I dont know the maximum number of pages that will be required. I tried using the FragmentStatePagerAdapter. I cannot understand the reason for NullPointerException as the data has been succesfully added to the arraylist? What would be best approach to doing this kind of dynamic addition of content to the views?
0 comments:
Post a Comment