kevindroidX
Lurker
Hi,
My layout shows up correctly, which I borrowed from the Android Developer's site, but the audio won't play. Perhaps I'm using the wrong context input to MediaCenter.create( ... ) ?
Here's my SpellThis class and main.xml is below
main.xml
Thanks!
My layout shows up correctly, which I borrowed from the Android Developer's site, but the audio won't play. Perhaps I'm using the wrong context input to MediaCenter.create( ... ) ?
Here's my SpellThis class and main.xml is below
Code:
public class SpellThis extends Activity implements View.OnClickListener {
public void onCreate(Bundle savedInstanceState) {
Button submitButton, replayButton;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
submitButton = (Button)findViewById(R.id.submitButton);
replayButton = (Button)findViewById(R.id.replayButton);
MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.mitochondria); // raw/mitochondria.mp3 is a working mp3
mp.start();
}
}
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Type here:"/>
<EditText
android:id="@+id/entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/label"/>
<Button
android:id="@+id/submitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/entry"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dip"
android:text="Submit" />
<Button
android:id="@+id/replayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/submitButton"
android:layout_alignTop="@id/submitButton"
android:text="Replay sound" />
</RelativeLayout>
Thanks!