Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap 3.x Android - Native Popup/Dialog Theme

I have a PhoneGap 3.1 project running on Android which is working fine - compiled with Android API lvl. 19. However, the native dialogs/alerts are using the Froyo/Android 2.x look and feel, whereas I'd like them to use the ICS/Android 4.x look and feel. In an older version of my , I did manage to get the dialog theme using ICS by updating the targetSDKVersion in AndroidManifest.xml. However, this has not worked in my 3.1 project.

This is an example of how they look in the version of my app running PhoneGap 2.5: ICSTheme

This is an example of how they look in my app running PhoneGap 3.1: GingerbreadTheme

I do believe this to be less of a PhoneGap issue, but more an Android Eclipse project setting. But I have the no idea what I need to change to fix this? Could someone advise please? Thanks!

like image 825
keldar Avatar asked Dec 03 '22 21:12

keldar


1 Answers

Don't worry - fixed it myself. For those who want to know, there is the following tag set in the default manifest file. By default, this is set to:

android:theme="Theme.Black.NoTitleBar"

Changing it to the following fixed it:

android:theme="Theme.DeviceDefault"

Quite simple I guess :).

Update

As of org.apache.cordova.dialog v2.9.0, the guys on the Cordova project changed the Android source to contain a default theme value to a hard coded value, as follows:

new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);

It is frustrating, but you can comment out this line and replace it with:

new AlertDialog.Builder(cordova.getActivity());

To restore previous behaviour and have Cordova use the value specified in AndroidManifest.xml.

like image 180
keldar Avatar answered Dec 23 '22 06:12

keldar