-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFragmentCry.java
54 lines (43 loc) · 1.57 KB
/
FragmentCry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.example.personal.newstart;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
public class FragmentCry extends Fragment {
Button Woman , Police ;
MediaPlayer woman_scream , man_scream,police_siren;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_cry , container , false);
Police = view.findViewById(R.id.police);
Woman = view.findViewById(R.id.woman);
// Man = view.findViewById(R.id.man);
woman_scream = MediaPlayer.create(getContext() ,R.raw.woman);
police_siren = MediaPlayer.create(getContext() , R.raw.police);
Police.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
police_siren.start();
}
});
Woman.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
woman_scream.start();
}
});
return view ;
}
@Override
public void onPause() {
super.onPause();
police_siren.pause();
woman_scream.pause();
}
}