Getting a variable out of a Public Void (Android)
Posted
by James Rattray
on Stack Overflow
See other posts from Stack Overflow
or by James Rattray
Published on 2010-04-21T17:44:42Z
Indexed on
2010/04/21
17:53 UTC
Read the original article
Hit count: 286
I have this code:
hubSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
final MediaPlayer mp2 = MediaPlayer.create(Textbox.this, R.raw.hero);
mp2.start();
}
public void onNothingSelected(AdapterView<?> parentView) {
}
});
(The code basically runs when a new item is selected of a spinner and then plays a song, -which later will be a variable based on what was picked, but i'm fine as it is for now)
Problem:
And I want to be able to use 'mp2' out of this public void, (I want a button which pauses it) How can I do this?
Please explain/show...
Thanks alot
James
© Stack Overflow or respective owner