Android初学第80天
Posted HankZhou
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android初学第80天相关的知识,希望对你有一定的参考价值。
android初学第80天
20_MVVM
代码
BeatBox
BeatBox.java
package com.bignerdranch.android.beatbox;
import android.content.Context;
import android.content.res.AssetManager;
import android.util.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class BeatBox {
private static final String TAG = "BeatBox";
private static final String SOUNDS_FOLDER = "sample_sounds";
private AssetManager mAssets;
private List<Sound> mSounds = new ArrayList<>();
public BeatBox(Context context) {
mAssets = context.getAssets();
loadSounds();
}
private void loadSounds() {
String[] soundNames;
try {
soundNames = mAssets.list(SOUNDS_FOLDER);
Log.i(TAG, "Found " + soundNames.length + " sounds");
} catch (IOException ioe) {
Log.e(TAG, "Could not list assets", ioe);
return;
}
for (String filename : soundNames) {
String assetPath = SOUNDS_FOLDER + "/" + filename;
Sound sound = new Sound(assetPath);
mSounds.add(sound);
}
}
public List<Sound> getSounds() {
return mSounds;
}
}
以上是关于Android初学第80天的主要内容,如果未能解决你的问题,请参考以下文章