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();

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

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐