mediaplayer button in viewpager
<p>Im new on android developing.. Every layout in my viewpager has a button and every button has a sound.. My problem is it doesn't make a sound when you click the button.. but there's no error in my code..</p>

<p>here's my code..</p>

<p>MainActivity.java</p>

<p>public class MainActivity extends FragmentActivity {</p>

<pre><code>private ViewPager _mViewPager;

private ViewPagerAdapter _adapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setUpView();
    setTab();
}
private void setUpView(){
 _mViewPager = (ViewPager) findViewById(R.id.viewPager);
 _adapter = new ViewPagerAdapter(getApplicationContext(),getSupportFragmentManager());
 _mViewPager.setAdapter(_adapter);
 _mViewPager.setCurrentItem(0);
}
private void setTab(){
        _mViewPager.setOnPageChangeListener(new OnPageChangeListener(){

                    public void onPageScrollStateChanged(int position) {}
                    public void onPageScrolled(int arg0, float arg1, int arg2) {}
                    public void onPageSelected(int position) {

                    }

                });

}
</code></pre>

<p>}</p>

<p>ViewPagerAdapter.java</p>

<p>public class ViewPagerAdapter extends FragmentPagerAdapter {
    private Context _context;</p>

<pre><code>public ViewPagerAdapter(Context context, FragmentManager fm) {
    super(fm);
    _context=context;

    }
@Override
public Fragment getItem(int position) {
    Fragment f = new Fragment();
    switch(position){
    case 0:
        f=Onep.newInstance(_context);
        break;
    case 1:
        f=Two.newInstance(_context);
        break;
    case 2:
        f=Three.newInstance(_context);
        break;
    }
    return f;
}

@Override
public int getCount() {
    return 3;
}
</code></pre>

<p>}</p>

<p>One.java</p>

<p>public class One extends Activity {</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    final MediaPlayer buttonClick1 = MediaPlayer.create(this, R.raw.click);

    Button button1 = (Button) findViewById(R.id.ganda);
    button1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            buttonClick1.start();
        }
    });
}
</code></pre>

<p>public static class Onep extends Fragment{</p>

<pre><code>public static Fragment newInstance(Context context) {
    Onep f = new Onep();

    return f;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.one, null);
    return root;

}
</code></pre>

<p>}
}</p>

<p>Please help me.. thanks in advance..</p>
