본문 바로가기
모바일개발(Mobile Dev)/안드로이드개발(Android)

to avoid overlap a previous menu view

by 테크한스 2016. 11. 12.
반응형
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

getView().setBackgroundColor(Color.WHITE);
getView().setClickable(true);
}

Well Setting up fragment background color is not a solution because fragment will be still in the activity stack which may consume memory.

Solution would be remove all views from your framelayout before adding any new fragment.

private void changeFragment(Fragment fr){
    FrameLayout fl = (FrameLayout) findViewById(R.id.mainframe);
    fl.removeAllViews();
    FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
    transaction1.add(R.id.mainframe, fr);
    transaction1.commit();
}


반응형