Android编程入门-第54天

xiaoxiao2021-02-28  30

Sound.java

public class Sound { private String mAssetPath; private String mName; public Sound(String assetPath) { mAssetPath = assetPath; String[] components = assetPath.split("/"); String filename = components[components.length - 1]; mName = filename.replace(".wav", ""); } public String getAssetPath() { return mAssetPath; } public String getName() { return mName; } }

SoundViewModel.java

import android.databinding.BaseObservable; import android.databinding.Bindable; import android.util.Log; public class SoundViewModel extends BaseObservable { private Sound mSound; private BeatBox mBeatBox; public SoundViewModel(BeatBox beatBox) { mBeatBox = beatBox; } @Bindable public String getTitle() { return mSound.getName(); } public Sound getSound() { return mSound; } public void setSound(Sound sound) { mSound = sound; notifyChange(); } }
转载请注明原文地址: https://www.6miu.com/read-2624727.html

最新回复(0)