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) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));

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

}
if(position==1){

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

});
}
asgar.ali
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Mar 28, 2011 5:44 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 16 guests