• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps linking buttons to other xml pages

bumpn111

Lurker
I'm developing an app for android. The main screen has 6 buttons. Each button leads to another screen. I'm having trouble with the code to make the buttons do anything when clicked. this is what I have: on the main page my button id is glass the page opened when clicked is glass.xml
PHP:
android:onClick="Intent i = new Intent(FirstActivity.this, SecondActivity.class);"
and my scr folder I have the java activities FirstActivity.java
PHP:
package install.fineline;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class FirstActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fine_line);

    Button btnload = (Button) findViewById(R.id.glass);
    btnload.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent i = new Intent(this, SecondActivity.class);
    startActivity(i);
}
}

and SecondActivity.java

PHP:
package install.fineline;

import android.app.Activity;
import android.os.Bundle;

public class SecondActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.glass);


}
}
what am i doing wrong?
 
Did you define them right? And connected them right? That might be the problem.
Give us the code so we can look more specific what the problem is.
 
Back
Top Bottom