I have a list of sounds, wanted to pick up each element from the list and output the sound that is recorded in the database. Example: when I click on an element that is in the list, I emit the recorded sound that is in the database, I already have everything recorded, just wanted to know how I do it to click the sound.
public static final String KEY_SOM = "NomeSom";
String Som = "CREATE TABLE IF NOT EXISTS tabSom3 ( '_id' INTEGER PRIMARY KEY AUTOINCREMENT, " +
"'NomeSom' TEXT, " +
"'ArqSom' TEXT);";
public void CarregaDadoSom(){
MostraDados = (ListView) findViewById(R.id.lstSom);
if(VerificaRegistroSom()){
String [] Coluna = new String [] {KEY_SOM};;
AdapterLista = new SimpleCursorAdapter(this, R.layout.lista_som, cursor, Coluna, new int[] {R.id.txtsom});
MostraDados.setAdapter(AdapterLista);
}else {
MensagemAlerta("Erro Banco de Dados", "Você não possui nenhum cadastro!");
}
}
private boolean VerificaRegistroSom() {
try {
BancoDados = openOrCreateDatabase(NomeBanco, MODE_WORLD_READABLE, null);
cursor = BancoDados.rawQuery("Select * from tabSom3", null);
if (cursor.getCount() != 0) { //procurar registro no banco
cursor.moveToFirst();
return true;
} else{
return false;
}
} catch(Exception erro){
MensagemAlerta("Erro Banco de Dados", "Não foi possivel VERIFICAR dados " + erro);
return false;
} finally {
BancoDados.close();
}
}
public void play(View view) {
try{
myPlayer = new MediaPlayer();
myPlayer.setDataSource(outputFile);
myPlayer.prepare();
myPlayer.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void stopPlay(View view){
try {
if (myPlayer != null) {
myPlayer.stop();
myPlayer.release();
myPlayer = null;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
'.xml':
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/txtsom"
android:layout_gravity="center_horizontal"
android:textSize="30dp" />
</LinearLayout>
Only the name of the sound appears in my list, but I wanted it to output the recorded sound.