Skip to content

Commit

Permalink
hzuapps#3 hzuapps#27 第三次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
AmoTF committed May 6, 2017
1 parent 51c51b3 commit b242aa5
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903222;
package edu.hzuapps.androidlabs.homeworks.net1414080903222;

import android.graphics.PixelFormat;
import android.media.MediaRecorder;
Expand All @@ -13,34 +13,66 @@

public class Net1414080903222Activity extends AppCompatActivity {

private Button btn_start, btn_stop;
private ListView lv_content;
private Button btn_start, btn_stop,btn_play;
private File sdcardfile = null;
private String[] files;
// private String[] files;
private MediaRecorder recorder = null;
private File file;
//文件路径
private String filePath;
//文件夹路径
private File FolderPath;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.TRANSLUCENT);// 让界面横屏
requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉界面标题
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// 重新设置界面大小
setContentView(R.layout.activity_net1414080903222);
setContentView(R.layout.first_fragment1414080903222);
initView();

getSDCardFile();
}



/**
* 实例化控件
* 实例化控件
*/
private void initView() {
btn_start = (Button) findViewById(R.id.Astart);
btn_stop = (Button) findViewById(R.id.Astop);
btn_play= (Button) findViewById(R.id.Aplay);

//时间控件
mImageView = (ImageView) findViewById(R.id.iv_recording_icon);
mTextView = (TextView) findViewById(R.id.tv_recording_time);


//给按钮添加监听事件
btn_start.setOnClickListener(this);
btn_stop.setOnClickListener(this);
btn_play.setOnClickListener(this);

//设置起始状态开始按钮可用,停止按钮不可用
btn_start.setEnabled(true);
btn_stop.setEnabled(false);
btn_play.setEnabled(false);

}

/**
* 获取内存卡中文件的方法
*/
private void getSDCardFile() {
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {//内存卡存在
sdcardfile = Environment.getExternalStorageDirectory();//获取目录文件

Toast.makeText(this, "找到内存卡", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "未找到内存卡", Toast.LENGTH_SHORT).show();
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background" android:drawable="@mipmap/record_top1414080903222" />
<item android:id="@android:id/progress" >
<clip android:drawable="@mipmap/record_bottom1414080903222" android:gravity="bottom" android:clipOrientation="vertical" />
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<corners
android:radius="8dp" />

<solid
android:color="@color/colorGray" />

</shape>
64 changes: 37 additions & 27 deletions AndroidLabs/app/src/main/res/layout/activity_net1414080903222.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,63 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="edu.hzuapps.androidlabs.homeworks.net1414080903222.Net1414080903222Activity">

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"

<LinearLayout
android:background="@drawable/record_microphone_bj1414080903222"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:padding="16dp"
android:layout_alignParentTop="true"
android:layout_marginTop="32dp"
android:text="Recording"
android:textAppearance="?android:attr/textAppearanceMedium" />

<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:scaleType="fitXY"
android:src="@android:drawable/presence_audio_online" />
android:layout_marginTop="55dp">

<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/iv_recording_icon"
android:src="@drawable/record_microphone1414080903222" />

<TextView
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:id="@+id/tv_recording_time"
android:layout_width="114dp"
android:textColor="#FFFFFF"
android:gravity="center"
android:textSize="16sp"
android:text="00:00" />
</LinearLayout>

<Button
android:id="@+id/Astart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_marginTop="67dp"
android:layout_toLeftOf="@+id/imageView1"
android:text="start" />
android:text="start"
android:layout_marginEnd="19dp"
android:layout_above="@+id/Aplay"
android:layout_toStartOf="@+id/Aplay"
android:layout_marginBottom="34dp" />

<Button
android:id="@+id/Astop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:text="stop"
android:layout_alignBaseline="@+id/Astart"
android:layout_alignBottom="@+id/Astart"
android:layout_alignRight="@+id/textView1"
android:layout_marginRight="40dp"
android:text="stop" />
android:layout_toEndOf="@+id/Aplay"
android:layout_marginStart="19dp" />

<Button
android:id="@+id/Aplay"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/Astop"
android:layout_centerHorizontal="true"
android:text="play" />
android:text="play"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />

</RelativeLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b242aa5

Please sign in to comment.