} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
/* 停止 */
myButton2.setOnClickListener(new ImageButton.OnClickListener()
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
if (myRecAudioFile != null)
{
/* 停止录音 */
mMediaRecorder01.stop();
/* 将录音文件名给Adapter */
adapter.add(myRecAudioFile.getName());
mMediaRecorder01.release();
mMediaRecorder01 = null;
myTextView1.setText("停止:" + myRecAudioFile.getName());
myButton2.setEnabled(false);
isStopRecord = true;
}
}
});
/* 播放 */
myButton3.setOnClickListener(new ImageButton.OnClickListener()
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
if (myPlayFile != null && myPlayFile.exists())
{
/* 开启播放的程序 */
openFile(myPlayFile);
}
}
});
/* ?除 */
myButton4.setOnClickListener(new ImageButton.OnClickListener()
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
if (myPlayFile != null)
{
/* 因将Adapter移除文件名 */
adapter.remove(myPlayFile.getName());
/* 删除文件 */
if (myPlayFile.exists())
myPlayFile.delete();
myTextView1.setText("完成删除");
}
}
});
myListView1.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3)
{
/* 当有点选文件名时将删除及播放按钮Enable */
myButton3.setEnabled(true);
myButton4.setEnabled(true);
myPlayFile = new File(myRecAudioDir.getAbsolutePath()
+ File.separator
+ ((CheckedTextView) arg1).getText());
myTextView1.setText("你选的是:"
+ ((CheckedTextView) arg1).getText());
}
});
}
@Override
protected void onStop()
{
if (mMediaRecorder01 != null && !isStopRecord)
{
/* 停止录音 */
mMediaRecorder01.stop();
mMediaRecorder01.release();
mMediaRecorder01 = null;
}
super.onStop();
}
private void getRecordFiles()
{
recordFiles = new ArrayList<String>();
if (sdCardExit)
{
File files[] = myRecAudioDir.listFiles();
if (files != null)
{
for (int i = 0; i < files.length; i++)
{
if (files[i].getName().indexOf(".") >= 0)
{
/* 读取.amr文件 */
String fileS = files[i].getName().substring(
files[i].getName().indexOf("."));
if (fileS.toLowerCase().equals(".amr"))
recordFiles.add(files[i].getName());
}
}
}
}
}