EDIT: If I extend FragmentActivity
instead of ActionBarActivity
my layout shows up again (without an ActionBar
of course).
The ActionBar
works as intended on 4.x
devices, but on my 2.3
device all I get is the ActionBar
and a blank screen below it. The Fragment
doesn't seem to be getting added to the Activity
.
themes.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarStyle">@style/Widget.ActionBar</item>
</style>
themes-v11.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
</style>
styles.xml
<style name="Widget.ActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@color/actionbar_background</item>
<item name="background">@color/actionbar_background</item>
</style>
Activity onCreate()
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
myFragment = new WallFragment();
fragmentTransaction.add(android.R.id.content,
myFragment, myFragment.FRAGMENT_TAG);
fragmentTransaction.commit();
I am using Gradle to include the AppCompat ActionBar
library in my app.
compile 'com.android.support:appcompat-v7:18.0.+'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…