Created
February 18, 2015 01:43
-
-
Save Nunocky/2cae700c03b38bed7a93 to your computer and use it in GitHub Desktop.
Android : 効果音の鳴らし方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlaceholderFragment extends Fragment { | |
private MediaPlayer mp; | |
public PlaceholderFragment() { | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
Bundle savedInstanceState) { | |
mp = MediaPlayer.create(getActivity().getApplicationContext(), R.raw.decision17); | |
View rootView = inflater.inflate(R.layout.fragment_main, container, false); | |
ButterKnife.inject(this, rootView); | |
return rootView; | |
} | |
@Override | |
public void onDestroyView() { | |
ButterKnife.reset(this); | |
mp.release(); | |
super.onDestroyView(); | |
} | |
@OnClick(R.id.button) | |
public void onButtonClicked() { | |
mp.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment