2011-04-01 76 views
0

我想在listfield黑莓Listfield与实时图像

+1

什么是'活'图像? – 2011-04-01 19:20:29

+0

所有包含实时图像URL的列表字段数据都来自web服务.i已成功传递所有数据,包括图像URL。但我不知道如何显示每行中的每个图像。使用listfield的 – 2011-04-02 02:27:38

+0

涉及为每一行写一个paint方法。我假设你已经完成了这部分。涂料的图像部分会发生什么?你可以包含截图吗? – 2011-04-02 06:42:30

回答

1

退房this

还使用下面的代码显示实时图像中的所有行,以显示与实时图像的listfield:

public static String getImageFromUrl(String url) { 
      //Image img = null; 
      String imageData = null; 
      try 
      {    
       imageData = getDataFromUrl(url); 
       //img = Image.createImage(imageData.getBytes(), 0,imageData.length());   
      } 
      catch(Exception e1) { 
       e1.printStackTrace(); 
      } 

      return imageData; 
     } 

     public static String getDataFromUrl(String url) 
       throws IOException { 

      StringBuffer b = new StringBuffer(); 
      InputStream is = null; 
      HttpConnection c = null; 

      long len = 0 ; 
      int ch = 0; 

      ConnectionFactory connFact = new ConnectionFactory(); 
       ConnectionDescriptor connDesc; 
       connDesc = connFact.getConnection(url); 

       if (connDesc != null) 
       { 
        //HttpConnection httpConn; 
        c = (HttpConnection)connDesc.getConnection(); 
       } 

      // c = (HttpConnection)Connector.open(url); 
      is = c.openInputStream(); 
      len = c.getLength(); 
      if(len != -1) { 
       // Read exactly Content-Length bytes 
       for(int i =0 ; i < len ; i++) 
        if((ch = is.read()) != -1) { 
        b.append((char) ch); 
        } 
      } else { 
       //Read until the connection is closed. 
       while ((ch = is.read()) != -1) { 
        len = is.available() ; 
        b.append((char)ch); 
       } 
      } 

      is.close(); 
      c.close(); 
      return b.toString(); 
     } 

希望这会帮助你。

+0

thanx Dinesh。我会试试这个。 – 2011-04-06 04:36:52

+0

thanx Dinesh。我会试试这个。 – 2011-04-06 05:31:27

+0

如果你接受答案,你应该点击右边的箭头。 – 2011-04-08 14:05:32