Howdy. Just getting into android programming and have ran into a snag. My program opens with a splash screen then goes to a menu screen with 3 buttons. The 2 buttons I've coded so far work, but the target class of one crashes. I know the buttons work because I had it go to a temp class I made and it went there fine.
Also, when I only have the basic code in the target class it works.
Also, when I only have the basic code in the target class it works.
That works, but the next one does not work. It crashes.package com.brggames.dquest;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
public class temp extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.hall1);
}
}
and here is the xml filepackage com.brggames.dquest;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
public class hallOne extends Activity {
MediaPlayer bclick1;
Button bForward1, bBack1, bLeft1, bRight1, Bpause1, bPlayMusic1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.hall1);
bclick1 = MediaPlayer.create(this, R.raw.bclick1);
Button bLeft1 = (Button) findViewById(R.id.bLeft1);
bLeft1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
bclick1.start();
}
});
Button bRight1 = (Button) findViewById(R.id.bRight1);
bRight1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
bclick1.start();
}
});
Button bForward1 = (Button) findViewById(R.id.bForward1);
bForward1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
bclick1.start();
}
});
Button bBack1 = (Button) findViewById(R.id.bBack1);
bBack1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
bclick1.start();
}
});
Button bPause1 = (Button) findViewById(R.id.bPause1);
bPause1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
bclick1.start();
}
});
Button bPlayMusic1 = (Button) findViewById(R.id.bPlayMusic1);
bPlayMusic1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
bclick1.start();
}
});
}
}
Any help would be appreciated.<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:layout_width="fill_parent"
android:id="@+id/imageView1"
android:layout_height="fill_parent"
android:src="@drawable/hall1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
<Button android:id="@+id/bPause1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Pause"
android:layout_alignTop="@+id/bPlayMusic1"
android:textStyle="bold"/>
<Button android:id="@+id/bBack1"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="B"
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:textStyle="bold"/>
<Button android:id="@+id/bForward1"
android:layout_above="@+id/bRight1"
android:layout_alignLeft="@+id/bBack1"
android:layout_centerHorizontal="true"
android:text="F"
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:textStyle="bold"/>
<Button android:id="@+id/bRight1"
android:layout_above="@+id/bBack1"
android:layout_toRightOf="@+id/bBack1"
android:text="R"
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:textStyle="bold"
android:focusableInTouchMode="false"
android:focusable="false"/>
<Button android:id="@+id/bLeft1"
android:layout_above="@+id/bBack1"
android:layout_toLeftOf="@+id/bBack1"
android:text="L"
android:layout_width="48dp"
android:layout_height="48dp"
android:textSize="24dp"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"/>
<ImageButton android:layout_height="wrap_content"
android:src="@drawable/play"
android:layout_width="wrap_content"
android:id="@+id/bPlayMusic1"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>