页面布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"> <Button android:id="@+id/start_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="开始录音" android:textSize="16sp" /> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="#d1d1d1" android:dividerHeight="1dp" android:scrollbars="none" android:layout_marginTop="10dp" android:layout_marginBottom="10dp"></ListView></LinearLayout>对应资源文件strings.xml:
<resources> <string name="app_name">mediarecorder</string> <string name="record_fail">录音失败</string> <string name="time_too_short">时间太短,请重新录音</string> <string name="play_over">播放完成</string> <string name="play_error">抱歉,播放发生异常</string> <string name="stop_by_up">松开停止录音</string> <string name="speak_by_press">按住说话</string> <string name="start_record">开始录音</string> <string name="stop_record">停止录音</string></resources>录音相关权限 :
<!--SD卡权限--> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <!--录音权限--> <uses-permission android:name="android.permission.RECORD_AUDIO"/>安卓录制播放音频:https://github.com/ldm520/Android_Media
新闻热点
疑难解答