Peterdeka
Peterdeka

Reputation: 387

Tabbed android application basic structure

I'm porting my app from iOS to Android and i want to give it the same tabbed layout as what happens with iOS tabbar.

I found out that currently the best way is an action bar with a fragment for each "tab". This is working, but i can't understand how to navigate inside every tab. For example: one tab fragment is a listfragment, when i tap on a list entry i want to push a new (fragment or activity?..suggestions) that displays details about that entry.

Inside the listfragment i'm using for the select event:

 getFragmentManager()
         .beginTransaction()
         .replace(what_goes_here?, detailsfrag)
         .commit();

anything i've tried just adds the detailsfrag above the listfragment.

Is this the correct layout? (3 tabs, one fragment each, and each one pushing fragments) Bonus question: difference between fragment and fragmentactivity?

Thanks a lot.

Upvotes: 0

Views: 126

Answers (2)

Peterdeka
Peterdeka

Reputation: 387

I ended up using an intent to launch a new FragmentActivity that however hides the actionmenu tabs. But this is the way it should be considering android best practices. As a matter of facts the fragment that i want to display should actually be an activity according to android's way of doing things. Also twitter's app works this way so i think it's the correct way.

Upvotes: 0

David
David

Reputation: 3418

You are on the right course. The .replace() function takes to fragments - the one that should be replaced by the other. First one identified by its container id - e.g. R.id.fragmentContainer. Second one identified by an reference. Link API

Upvotes: 1

Related Questions