• 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
Oct 18, 2012
1
0
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?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones