2

I want to display HTML tag in RIM BB component BrowserField.

String str ="<html><body><p><img alt=\"bun\" src=\"http://adodis.in/ram/services/images/stories/food/bun.jpg\" width=\"150\" height=\"112\" /></p></body></html>";

BrowserField browserField = new BrowserField();
browserField.displayContent(str, "http://localhost");
add(browserField); 

How to display above tag in BrowserField? Using Blackberry OS 5.0

Thanks very much in advance..

user1134427
  • 111
  • 1
  • 8
  • are you just trying to figure out how to display a string of HTML content in a BrowserField, or are you already doing that, and the image above is not displaying correctly? – Nate Sep 13 '12 at 09:49
  • I can display other content like


    tags. But cannot display image.

    – user1134427 Sep 13 '12 at 09:57
  • can you show the java code that you use to display this in your `BrowserField`? normally, the `` tag should display just fine. also, which version of BlackBerry OS are you using? – Nate Sep 13 '12 at 10:06
  • String str ="

    \"bun\"

    "; browserField.displayContent(str, "http://localhost"); I am using Blackberry OS 5.0
    – user1134427 Sep 13 '12 at 10:15
  • can you **edit** your question above, and post the code into there? then, you can use the **{ }** button to format it as *code*. that works better than trying to do it in a comment. thanks. – Nate Sep 13 '12 at 10:17

1 Answers1

2

If you run your app, and you see the label "bun" displayed (the alt text), then I think the problem is just that you don't have network connectivity. Check your network, especially if you're using the simulator (you can just run the Browser app and try a known URL).

If you are seeing nothing where the image should be, then I think the problem is just that you call displayContent() before you add() the BrowserField to its parent manager.

So, just change the order of your calls, to call displayContent() last:

BrowserField browserField = new BrowserField();
add(browserField); 

String str ="<html><body><p><img alt=\"bun\" src=\"http://adodis.in/ram/services/images/stories/food/bun.jpg\" width=\"150\" height=\"112\" /></p></body></html>";
browserField.displayContent(str, "http://localhost");

Also, you don't really need to specify the img width and height properties in your HTML snippet, as that's the size of the actual image file. But, that doesn't actually cause a problem ... it's just extra HTML code.

Nate
  • 31,017
  • 13
  • 83
  • 207