-4

Here I'm trying to create Login email and password functions.
the app works fine for this code of yours below:

public class StartActivity extends AppCompatActivity {

    private Button mRegButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        mRegButton = (Button) findViewById(R.id.start_reg_btn);
        mRegButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent regIntent = new Intent(StartActivity.this, RegisterActivity.class);
                startActivity(regIntent);
            }
        });
    }
}

But when i add the code below to make the login button work, the app crashes:

public class StartActivity extends AppCompatActivity {
    private Button mRegButton;
    private Button mLoginButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        mRegButton = (Button) findViewById(R.id.start_reg_btn);
        mRegButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent regIntent = new Intent(StartActivity.this, RegisterActivity.class);
                startActivity(regIntent);
            }
        });

        mLoginButton = (Button) findViewById(R.id.login_btn);
        mLoginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent loginIntent = new Intent(StartActivity.this, Login.class);
                startActivity(loginIntent);
            }
        });
        }
}

please help. i have been wasting almost 4 hour trying to figure what is happening, but failed to get the problem solved.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

2 Answers2

2

Like Everyone will always tell you, for this kind of problems you have 2 choices:

read your stack trace and figure out the problem yourself

or

provide your stack trace

In both situations you need to be aware of the problem to solve it. Since you're new to programming here, have a look at these topics, they will help you greatly solving this problem and many more problems you will encounter in the future:

How to solve application crash

What is stack trace

Rayhane Mama
  • 2,374
  • 11
  • 20
0

You have to check Login.Class logcat traces what is error. Since, issue is in the login class so it's unable to Launch startActivity intent when you click on LoginButton.

user8119020
  • 117
  • 3