whemexico.blogg.se

Android studio fragment not attached to activity
Android studio fragment not attached to activity












android studio fragment not attached to activity android studio fragment not attached to activity android studio fragment not attached to activity

However now I am getting to the point where my Activity will be implementing 2 – 4 different interfaces which is making me hesitant because it will severely reduce cohesion. I then tried to have the Activity implement the listener directly which works because then I am only creating a dependency with the listener and not the Activity. But I had problems because I had to use New MyActivity().new Listener() and it would throw an Exception when I tried to use getSupportFragmentManager() since this instance of the Activity is not initialized. So I created a class in the Activity to implement the listener interface. Next I tried a listener to notify the Activity that it should show a Fragment. I tried to use getActivity() and cast it so I can call a method in the Activity to show a Fragment however this creates a dependency in the Fragment with the Activity and I would like to avoid adding a dependency if possible. I know that an Activity should be the one tasked with opening Fragments so instead I have tried a couple things. I want to show a DialogFragment or open another Fragment from one of the Fragments. I have an Activity with multiple Fragments.














Android studio fragment not attached to activity