首页上一页 1 下一页尾页 1 条记录 1/1页
com.example.myapplication; androidx.annotation.; androidx.appcompat.app.AppCompatActivity; android.media.AudioAttributes; android.media.SoundPool; android.os.Build; android.os.Bundle; android.view.View; android.widget.AdapterView; android.widget.ListView; java.util.HashMap; MainActivity AppCompatActivity { (api = Build.VERSION_CODES.) onCreate(Bundle savedInstanceState) { .onCreate(savedInstanceState); setContentView(R.layout.); ListView listView =(ListView) findViewById(R.id.);AudioAttributes atttr =AudioAttributes.Builder() .setUsage(AudioAttributes.) .setContentType(AudioAttributes.).build(); SoundPool soundPool=SoundPool.Builder() .setAudioAttributes(atttr).setMaxStreams().build(); HashMap<Integer,Integer> soundmap=HashMap<Integer, Integer>();soundmap.put(,soundPool.load(,R.raw.,)); soundmap.put(,soundPool.load(,R.raw.,)); soundmap.put(,soundPool.load(,R.raw.,)); soundmap.put(,soundPool.load(,R.raw.,)); soundmap.put(,soundPool.load(,R.raw.,)); listView.setOnItemClickListener(AdapterView.OnItemClickListener() { onItemClick(AdapterView<?> parent, View view, position, id) { .play(.get(position),,,,,); } }); } }