Search code examples
androidandroid-tabhostandroid-alertdialogandroid-tablelayoutandroid-tabactivity

Open alertDialog inside a Tabview which is inside another tabview


I have a tab view inside that tab view, another tab view inside that tab view`, and a alert box. When I try to open it my application gets force closed.

enter image description here

But that same AlertDialog is working fine on first tab view.


Solution

  • You must be making the mistake with passing the context to the alertdialog this is a very common mistake.

    you must pass the context as getParent() not "this" beacause working with tabs it's not your activity that's running it's the parent activity displaying the contents of your activity I could have helped you better if you had posted some code.