android - How do I add a fragment to a view when its context is Application? -


i need add fragment view dynamically it's inside fragment (see answer https://stackoverflow.com/a/6847770/811405).

the whole structure this:

fragment | |---viewholder     |     |---(dynamically added fragment) 

in viewholder, have access view. i've first thought call getcontext() , cast activity, use it's fragment manager add it. however, getcontext returns application object, not activity (it's called on app launch before app physically on screen, maybe activity hasn't been created yet).

how can add fragment dynamically on viewholder? (of course, without using terrible anti-patterns)

my real problem inflating layout incorrect context (yup, guessed right, application instance) instead of activity. i've fixed code make inflate activity, , getcontext returns activity. fragment manager , add fragment normally.


Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

python - matplotlib equivalent for Ubuntu servers with no GUI? -