2011-02-14 59 views
0

我正在製作一個將會有圖像的應用程序。當用戶點擊下一個按鈕時,應用程序將顯示下一個圖像。如何從服務器查看應用程序中的圖像?

這跟將要託管圖像和下一個按鈕被擊中的圖像在服務器,轉到應用服務器完成,

我怎樣才能做到這一點。

例APP IDEA OF ...

App1的

Button1的=先前

將Button2 =接着

服務器/主機

IMAGE1

圖像2

的Image3

圖像4


當BUTTON2(NEXT)被點擊它將從服務器顯示圖像2

當將Button2(NEXT)被點擊AGAIN它將從服務器顯示的Image3

-BUT-

當按鈕1(前一個)被點擊時,它將顯示前一個圖像(例如鏡像2)

-

真誠,

IntelSoftApps

[email protected]

IntelSoftApps.com

回答

1
/*********************************************************** 
    * This method will return the image from a URL. We will input 
    * the item image URL. 
    ***********************************************************/ 
    public Drawable getRemoteImage(final URL aURL) { 
     try { 
      final URLConnection conn = aURL.openConnection(); 
      conn.connect(); 
      final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream()); 
      final Drawable d = Drawable.createFromStream(bis, "src"); 
      bis.close(); 
      return d; 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     return null; 
    } 

你應該從一個單獨的使這個方法調用線程以便在獲取時不凍結UI拍照。將圖像作爲Drawable後,您只需設置ImageView即可顯示它。

imageView.setImageDrawable(myImage); 
相關問題