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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -

php - Autoloader issue not returning Class -