Adding Title Back To Android Window When Using Phonegap
Solution 1:
Phonegap / Cordova version 1.9 added a flag to toggle this feature:
if(!this.getBooleanProperty("showTitle", false))
{
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
Example onCreate method that enables window title:
@OverridepublicvoidonCreate(Bundle savedInstanceState) {
// enable window title for actionbar supportsuper.setBooleanProperty("showTitle", true);
super.onCreate(savedInstanceState);
}
Solution 2:
Have you tested FEATURE_CUSTOM_TITLE
?
getWindow().requestFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setTitle(getResources().getString(R.string.app_name));
or try loading Theme with title bar:
setTheme(android.R.style.choose some of the themes listed or create your own);
Solution 3:
So, I ended up not being able to solve this without modifying the original code. What I ended up doing was copying the DroidGap class into my own class (source code linked in the post) and commented out the following line:
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Then, I extended my normal activity with my modified version of DroidGap, not PhoneGap's version.
Then, in my activity's onCreate, I have something like this:
publicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
ActionBarbar= getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.addTab(bar.newTab().setText("Home").setTabListener(newCustomTabListener()));
bar.addTab(bar.newTab().setText("Something").setTabListener(newCustomTabListener()));
loadUrl("file:///android_asset/www/index.html");
}
Without the requestFeature, you'll get null
from the getActionBar()
.
Hope it helps someone else!
Solution 4:
Check the Android Manifest. I found that phonegap generates an Android manifest that specifies android:theme="@android:style/Theme.Black.NoTitleBar". Changing this theme allowed me to control the title display from code.
Post a Comment for "Adding Title Back To Android Window When Using Phonegap"