开发者

Blackberry Listfield with Live Image

开发者_开发百科I want to display a listfield with live image in all rows of the listfield


check out this

also use the following code for displaying live images:

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();
        }  

Hope this will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜