1. 程式人生 > >android應用中為按鍵新增聲音

android應用中為按鍵新增聲音

    soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100); 
    soundPoolMap = new HashMap<Integer, Integer>();   
    soundPoolMap.put(1, soundPool.load(this, R.raw.dingdong, 1)); 

  soundpool的載入: 
      int  load(Context context, int resId, int priority)  //從APK資源載入 
  int  load(FileDescriptor fd, long offset, long length, int priority)  //從FileDescriptor物件載入 

  int  load(AssetFileDescriptor afd, int priority)  //從Asset物件載入 
  int  load(String path, int priority)  //從完整檔案路徑名載入 
最後一個引數為優先順序。