How to play audio using this code in Grid View

All your problems with Audio, Video and Images.

How to play audio using this code in Grid View

Postby asgar.ali » Mon Mar 28, 2011 6:30 pm

Hi ,
I have been following this code on andriod developer site. This code displays pictures in a grid. What I want to do now is to play different sond each time user clicks on the image. How can I do that?
public void onCreate(Bundle savedInstanceState) {
GridView gridview = (GridView) findViewById(;
gridview.setAdapter(new ImageAdapter(this));

gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Intent myIntent = null;
//Play some sound...
//MediaPlayer sound= MediaPlayer.create(this,R.raw.alif);
// sound.start();


Toast.makeText(Test.this, "" + "Baa",Toast.LENGTH_SHORT).show();

Once Poster
Once Poster
Posts: 1
Joined: Mon Mar 28, 2011 5:44 pm


Return to Multimedia Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 5 guests