Error:(31, 32) error: incompatible types: FragmentOne cannot be converted to Context


Am trying to play sounds so I can make a soundboard app, have decided to make it a sliding app to change between activities but it won't let me add the sound pool. Error is happening between the two **. Please help me, am new to coding.

package com.jonatboard.jonat.htssoundboard; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.media.SoundPool; import android.media.AudioManager; public class FragmentOne extends Fragment { SoundPool Clubb1; int clubb1Id; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Clubb1 = new SoundPool(10, AudioManager.STREAM_MUSIC, 1); clubb1Id = Clubb1.load**(this, R.raw.clubb1,1)**; // TODO Auto-generated method stub return inflater.inflate(R.layout.fragment_one_layout, container, false); }}


you can use getActivity() to retrieve the activity's context where FragmentOne is inflated.


clubb1Id = Clubb1.load(this, R.raw.clubb1,1);


clubb1Id = Clubb1.load(getActivity(), R.raw.clubb1,1);


  • Transparent Background and No Buttons When Customizing Content of an AlertDialog on onPrepareDialog
  • Why Touch not work on google map v2?
  • Android Music Player inside a fragment
  • ScrollView: java.lang.StackOverflowError
  • Why setOnCheckedChangeListener not working in a popup that uses LayoutInflater?
  • Display Two Fragments at the same time
  • Binary XML file line #26: Duplicate id, tag null, or parent id with another fragment
  • Add multiple images and text to each ViewPager slide
  • Toggle button in a list view loose their state when scrolled of screen in Android
  • What other Adapters can I use for ListView?
  • How to send an std::vector of unsigned char over an UDP socket using boost asio?
  • Listview with multiple strings
  • ActionBar with appcompat library v7 (ava.lang.IllegalStateException: You need to use a Theme.AppComp
  • Android TabLayout on the bottom of the screen
  • Drag and Drop for imageview not working
  • ResponseBuilder is not working when used with entity object
  • Is it possible to control programs with Javascript?
  • Is the listview recycling early? Or is Universal ImageLoader canceling in error? Or is my Logic wron
  • How to Make a Spinner (In a Fragment) That Changes the App's Language?
  • How to get listview position?
  • Syntax error on tokens, AnnotationName expected instead - error on query
  • Connect .sks to skscene.h
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • azure media services - The request body is too large and exceeds the maximum permissible limit
  • Hardware Accelerated Image Scaling in windows using C++
  • How to test if a URL from an Eclipse bundle is a directory?
  • Cannot resolve symbol 'MyApi'
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Obtain ObjectIdHex value from mgo query
  • Can I make an Android app that runs a web view in Chrome 39?
  • Release, debug version and Authorization Google?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Apache 2.4 - remove | delete | uninstall
  • Return words with double consecutive letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • Python: how to group similar lists together in a list of lists?
  • How to include full .NET prerequisite for Wix Burn installer
  • How do you join a server to an Active Directory (domain)?
  • Understanding cpu registers
  • Busy indicator not showing up in wpf window [duplicate]