App Stops unexpectedly after adding button to xml

EmbobFlub

New Member
Brand new to Android and I have made a very basic app which just displays a background picture and some text. I now want to add a button to main.xml using android:onClick which displays a toast message but I am having problems.My main.xml is as follows:\[code\]<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@drawable/bckgr"><TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="text writing text writing text writing"/><ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="center" android:src="http://stackoverflow.com/questions/10854422/@drawable/logo" /><Button android:id="@+id/myclick" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Next Picture" android:onClick="next" /></LinearLayout>\[/code\]My MainActivity.java is as follows. I am aware that I have assigned an ID to the button but this is not being used anywhere?\[code\]package com.example;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Toast;public class MyActivity extends Activity{/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); public void next (View v) { Toast.makeText(this, "Button clicked!", Toast.LENGTH_SHORT).show(); }}\[/code\]From what I understand the button calls the 'next' method from the main activity class when clicked which is supposed to display the toast message? There are no errors showing but at runtime the app stops unexpectedly. Any help is appreciated.
 
Back
Top