2013-04-29 70 views

回答

7

獲取你onCreate操作欄:

ActionBar actionBar = getSupportActionBar(); 

創建並加載動畫繪製其you defined in XML

// homeDrawable is a field on your activity 
homeDrawable = (AnimationDrawable) getResources().getDrawable(R.drawable.my_thing); 

設置繪製的操作欄上的圖標:

actionBar.setIcon(homeDrawable); 

發佈Runnable啓動當主線程清除時的動畫:

getWindow().getDecorView().post(new Runnable() { 
    @Override public void run() { 
    homeDrawable.start(); 
    } 
}); 

不要忘記停止動畫在某個時刻!