Focus lost after Fragment Change (ANDROID TV)

761 Views Asked by At
 public void changeFragment(String str) {


    SecFragment nextFrag = new SecFragment();
    Bundle args = new Bundle();
    args.putString("site", str);
    nextFrag.setArguments(args);
    getFragmentManager().beginTransaction()
            .replace(((ViewGroup) getView().getParent()).getId(), nextFrag)
            .commit();


}

This is my way to change a fragment in my Android TV app. But after changing I cant navigate in my 2nd Fragment. The focus gets lost.

I am actually using a copy of the Mainfragment just with other information, here is the 2ndFragment´s onactivitycreated method

@Override
public void onActivityCreated(Bundle savedInstanceState) {

    Bundle bundle = getArguments();
    if (bundle != null) {
        site = bundle.getString("site");
    }

    super.onActivityCreated(savedInstanceState);
    page = 1;

    list = new ArrayList<Movie>();
    prepareBackgroundManager();

    setupUIElements();
    loadRows1();
    setupEventListeners();
    Bitmap mIcon = BitmapFactory.decodeResource(act.getResources(), R.drawable.splash);
    bm = BackgroundManager.getInstance(act);
    //bm.attach(act.getWindow());
    bm.setBitmap(mIcon);

    SetupVideos(site);

}

Both Fragments extend to the same BrowseFragment Class which is included in Android Studio

1

There are 1 best solutions below

3
Fadman On

You should use the addToBackStack() which would make it easier to navigate.