harsha.cs
harsha.cs

Reputation: 132

android display actionbar when two fragments are displayed

Android experts,

please help me in this issue. I have created two fragments aligned side by side for android tablet. When the user clicks on ListView in left side, the relevant activity is loaded on right side. Now the problem is, I want to display action bar in each of my activity screens, but in this screen the ActionBar is not seen. As I am loading fragments on list item click, I have my xml in this format

<LinearLayout>
<FrameLayout/> --left fragment
<FrameLayout/> --right fragment
</LinearLayout>

Now, if I put ActionBar code like

<include android:layout="@layout/actionbar">
<LinearLayout>
<FrameLayout/> --left fragment
<FrameLayout/> --right fragment
</LinearLayout>

This is not displaying ActionBar in the top. Please help me.

Thanks

Upvotes: 1

Views: 146

Answers (1)

harsha.cs
harsha.cs

Reputation: 132

I achieved this by using FragmentActivity. The code is as follows,

FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(FragmentA.this.getParent().getID(), mNewFragment);
ft.addToBackStack(null);
ft.commit();

Upvotes: 1

Related Questions