Programmatically adding a new fragment causes flickering

I have an application. For example, I have an AccountActivity. This action shows the list. When the element is clicked (i.e. Payment Types), I replace the main content with PaymentFragment. When an option is selected in PaymentFragment (e.g. new credit card added), I replace the main content of AddCCFragment. This all happens in AccountActivity. I am just replacing the fragments.

The problem is, if I programmatically add a fragment to the AddCCFragment, the screen flickers for a short time.

Here's a flicker-free example:

  • AccountActivity has FrameLayout which contains ListView
  • AccountActivity has FrameLayout which contains PaymentFragment
  • AccountActivity has FrameLayout which contains AddCCFragment

Here's a blinking example:

  • AccountActivity has FrameLayout which contains ListView
  • AccountActivity has FrameLayout which contains PaymentFragment
  • AccountActivity has FrameLayout which contains AddCCFragment which adds FragmentABC programmatically

In step 3, flickering occurs.

Thank.

+3


source to share





All Articles