Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:37:25+00:00 2026-06-08T06:37:25+00:00

When I launch the application and click the button to go to the Activity,

  • 0

When I launch the application and click the button to go to the Activity, I suddenly get a Force Close. I’ve tried to erase it all and write it again, but it is still there. What could be the problem?

package com.alexgascon.formuladora; 

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



public class Matematicas extends Activity {

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    final Button BtnEcSegundoGrado = (Button)findViewById(R.id.ecsegundogrado);
    final Button BtnFracciones = (Button)findViewById(R.id.fracciones);
    final Button BtnMCD = (Button)findViewById(R.id.maximocomunBoton);


    BtnMCD.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View arg0) {
            Intent MCDintent = new Intent(Matematicas.this,Maximocomun.class);
            startActivity(MCDintent);

        }


    });

}
}

And here is the layout code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@drawable/pizarramatesverde"
 android:gravity="center" >

<Button
    android:id="@+id/ecsegundogrado"
    android:layout_height="wrap_content"
    android:layout_width="265sp"
    android:text="@string/ecsegundo"
    android:textColor="@color/Negro"
    />
<Button
    android:id="@+id/fracciones"
    android:layout_height="wrap_content"
    android:layout_width="265sp"
    android:text="@string/fracciones"
    android:layout_below="@id/ecsegundogrado"
    android:textColor="@color/Negro"
    />

<Button
    android:id="@+id/maximocomunBoton"
    android:layout_height="wrap_content"
    android:layout_width="265sp"
    android:text="@string/maximocomun"
    android:layout_below="@id/fracciones"
    android:layout_marginBottom="80sp"
    android:textColor="@color/Negro"
    />



</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:37:27+00:00Added an answer on June 8, 2026 at 6:37 am

    You need to call setContentView before findViewById:

    setContentView(R.layout.yourlayoutxmlname);
    final Button BtnEcSegundoGrado = (Button)findViewById(R.id.ecsegundogrado);
    final Button BtnFracciones = (Button)findViewById(R.id.fracciones);
    final Button BtnMCD = (Button)findViewById(R.id.maximocomunBoton);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following exception when i launch my application through JWS.But it works
I have an asp.net application, where the user would click a button and launch
I 'm trying to launch the camera app on button click but I don't
When i try to launch my application from Xcode to the device, i get
Is it possible to Launch an application or activity from onRecieve() of a BroadcastReceiver
I want to launch from my application the activity recent apps, without holding on
I want to launch an application that already exist in device on the click
I am willing to add a button in my application which on-click will restart
I'm in a WindowsForm (c# .net 3.5) and on click of a button launch
My Application have 5 activities(A1,A2,A3,A4,A5). Each activity have one text view and one button(B1,B2,B3,B4,B5).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.