MVP for Android

Have you ever had problems with the lifecycle of an Activity or Fragment? The necessity to handle things like a configuration change, an activity kill because of low memory issues, removal of the entire app process, etc. always distinguished Android mobile enviroment from other application runtime enviroments. In our Android world there are many platform specific … 

 

Fragments – every day tips

#Tip 1 – static newInstancemethod pattern Note: Avoid setter methods and parametrized constructors to modify fragment state, because platform uses only default (0 parameter) constructor, arguments bunde and saved state bundle to restore it later.

  #Tip 2 – single fragment in Activity If your activity role is only to show fragment don’t create custom layout … 

 

Fragments restoration magic (mechanism)

In my last post, where I described a problem of incorrect usage of Fragments instantiation inside FragmentPageAdapter & ViewPager, I wrote: After orientation change all fragments currently added to FragmentManager are automatically restored and instantiated so there is no need to create them once again. Today, I want to focus more specifically on an issue how … 

 

Fragments in ViewPager

Using ViewPager with FragmentPagerAdapter or FragmentStatePagerAdapter appears to be quite easy and enjoyable. It could be done within few simple steps: Create layout .xml resource with ViewPager Create adapter and implement all required methods Set adapter instance to your ViewPager instance. Simple? Yes! – but like always only for easiest (also the most common) case Problem occurs when …