Seeking help for writing a TabLayout using Fragment

I am new to Android development. Recently I have been trying to rewrite the following tutorial with Fragment class. The tutorial utilizs the old TabActivity class and TabHost and TabWidget annontations.

I following some online Fragment sample codes, I converted all my Activity class with Fragment class, but I couldn't make it to work.

Here are few questions

1. Should I define the <Fragment> class or calling ActionBar.addBar(...), or both?2. What would a complete res/layout/main.xml look like? What would be the root element (i.e. LinearLayout, Framelayout..etc)?3. Any additional info would be grateful.