Skip to content

Instantly share code, notes, and snippets.

@Nunocky
Created February 18, 2015 01:43
Show Gist options
  • Save Nunocky/2cae700c03b38bed7a93 to your computer and use it in GitHub Desktop.
Save Nunocky/2cae700c03b38bed7a93 to your computer and use it in GitHub Desktop.
Android : 効果音の鳴らし方
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