在android中进行录音相对来说是比较简单的,使用系统提供的MediaRecorder类进行录音并保存,然后调用MediaPlayer进行播放。以下为xml配置文件代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.kk.soundrecording.MainActivity" >
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="@string/start" />
<Button
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/start"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="@string/stop" />
<Button
android:id="@+id/paly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/stop"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="@string/paly" />
<Button
android:id="@+id/pause_paly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/paly"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:text="@string/pause_paly" />
<Button
android:id="@+id/stop_paly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@