Refresh or force redraw the fragment

后端 未结 8 1625
失恋的感觉
失恋的感觉 2020-11-30 02:10

I have a fragment that inflates an xml layout. My requirement is to update the text size on all my views inside my fragment when my Activity is resumed. I tried



        
相关标签:
8条回答
  • 2020-11-30 02:52

    This worked for me from within Fragment:

    Fragment frg = null;
    Class fragmentClass;
    fragmentClass = MainFragment.class;
    
    try {
        frg = (android.support.v4.app.Fragment)     
        fragmentClass.newInstance();
    } catch(Exception ex) {
        ex.printStackTrace();
    }
    
    getFragmentManager()
        .beginTransaction()
        .replace(R.id.flContent, frg)
        .commit();
    
    0 讨论(0)
  • 2020-11-30 03:01

    I am using remove and replace both for refreshing content of Fragment like

    final FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.remove(resetFragment).commit();
    fragmentTransaction.replace(R.id.frame_container,resetFragment).commit();
    
    0 讨论(0)
提交回复
热议问题