how to link a java class to a image button in eclipse?
- by Isabella Chan
I am trying to create a application that includes a Imagebutton and by clicking on the imagebutton, the application will start to run another java class that is within the package itself. I try using this method, however the program stopped working immediately? how should i code the codes instead? can anyone help me? Thanks :D
package com.fyp.gulliver;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class GulliverActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //---Map button---
        Button btnMap = (Button) findViewById(R.id.map);
        btnMap.setOnClickListener(new View.OnClickListener() {
        Class ourClass; 
            public void onClick(View v) {
                // TODO Auto-generated method stub
                try {
                    ourClass = Class.forName
                        ("com.fyp.gulliver.Maps");
                    Intent ourIntent = new Intent(GulliverActivity.this, ourClass);
                    startActivity(ourIntent);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });
    } 
}