Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2008

    Using images within an Alert

    i'm trying to use an Alert displayable in my midlet. instead of using text, i want to display an Image within this alert.
    the following line in my code sets up this alert:

    alert = new Alert(null, null, wowImage,null);

    however when the alert is displayed on the screen, the image alignment is shifted too much to the right so as a result, only the left quarter of the image is seen. further, despite my setting the Alert title to "null", the alert carries the title of "Alert" when its displayed. this problem is only appearing on S60 devices. the same code works perfectly on S40.

    any inputs / workarounds would be greatly appreciated.


  2. #2
    Super Contributor
    Join Date
    Apr 2007

    Re: Using images within an Alert

    u might want to give it the text "" instead of null this might take away the Alert text, even though im not so sure, the Alert text might be dependable from the type of alert (error, message etc)...
    and with the images u have to test a little cause the image-size is very important.. Personally I've seen that certain S40's actually cut a piece of the image and display it whilst some s60 sometimes dont even display it if its not of the right size... u might want to start out pretty small as in 35x35 pixels or something

  3. #3
    Registered User
    Join Date
    May 2008

    Re: Using images within an Alert

    putting the text and title as "" doesnt make any difference. however if i use " " (i.e. a single blank space) then at least the "Alert" message does not appear.
    the problem with the image going off the screen still persists. i'm working out a custom splash screen for my program instead of using the Alert.
    for the benefit of others who might be facing a similar problem - refer to the JAVA ME Developer's Library v2.3 that is available on Forum Nokia. the section on implementation guidelines for images and icons talks a bit about using images in an Alert. from what i understand, the "image" within an alert is actually the icon. by default you have icons like the tick mark for AlertType.CONFIRMATION and the "x" for AlertType.ERROR etc. if you use the following Alert Constructor:

    alert = new Alert(String title, String text, Image image, AlertType type)

    in this case, the image that you are parsing replaces the default alert icon for the corresponding AlertType. further, passing null for the AlertType parameter results in "Alert" being displayed.
    on the basis of this, i think the issue here is that the image must conform to the dimensions of the Alert Icons for various display sizes. (again refer to the Implementation guidelines mentioned above which list out the various icon dimensions for all screen variants of S60 and S40)
    since my image is considerably bigger than these listed dimensions, only a small part of the image is being displayed ... in a sense the image is 'cropped' from the top left corner.
    i'm not sure when this library was last updated, but i can confirm that on S40 Feature Pack 2, this problem does not exist. as tiger mentions in his post - it is likely that the S40 is "cutting" the image to fit it on screen, but since the image is centrally aligned, i really cant make out the difference.

    also, one of the books on MIDP 2 (by Jonathan Knudsen) mentions that different platforms implement the Alert in their own ways. some will not show the image passed on as a parameter. however in ALL cases, the Title and the Text will ALWAYS be displayed.

    ~hope this helps ppl who face a similar issue!!!

Similar Threads

  1. Incorrect rgb values for jpg images on S40 3rd ed
    By bjudfar in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-05-29, 16:34
  2. Alert confusion
    By Peanuts1971 in forum Mobile Java General
    Replies: 2
    Last Post: 2007-05-29, 04:40
  3. 3230 images in an alert not transparent
    By ianstrain in forum Mobile Java General
    Replies: 0
    Last Post: 2006-12-13, 11:42
  4. Images in an Alert
    By Daniman in forum Mobile Java General
    Replies: 2
    Last Post: 2004-10-08, 08:02
  5. Problem with PNG Images
    By cyphre666 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2003-12-12, 18:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts