2011-09-12 66 views

回答

-1
private static class GIFView extends View{   
      Movie movie; 
      InputStream is=null; 
      long moviestart; 
      public GIFView(Context context) 
      { 
       super(context); 
       is=context.getResources().openRawResource(R.drawable.smile); 
       movie=Movie.decodeStream(is);     
      } 

      @Override 
      protected void onDraw(Canvas canvas) 
      { 
       super.onDraw(canvas); 

       long now=android.os.SystemClock.uptimeMillis(); 

       if (moviestart == 0) { // first time 
        moviestart = now; 
       }    
        int relTime = (int)((now - moviestart) % movie.duration()) ;     
        movie.setTime(relTime); 
        movie.draw(canvas,100,100); 

        this.invalidate(); 
      }       
     }  

使用這個類和視圖添加到您的佈局,

GIFView view=new GIFView(this); 

      linear=(LinearLayout)findViewById(R.id.linear); 
      linear.addView(view); 

它可以幫助你..

+0

hi.thanq..for您的回覆,但使用的PhoneGap框架IM(只有html頁面正在工作).im在瀏覽器中執行html它的工作,但不是在模擬器 – bhargavkumar040

+0

嘿,同樣的問題,但解決方案不給予phonegap! – byJeevan