Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Android studio error: illegal start of type }); ^

Its a very simple login activityI’ve tried putting parentheses and braces everywhere, it must be something obvious but I can’t find it.

API 28

Compile sdk 33

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

package com.example.listademercado;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast;

public class TelaDeLogin extends AppCompatActivity {

EditText login_tv, password_tv;
Button btnLogin;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tela_de_login);

    login_tv = (EditText) findViewById(R.id.login);
    password_tv = (EditText) findViewById(R.id.password);

    btnLogin = (Button) findViewById(R.id.button_login);

    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            String username = login_tv.getText().toString();
            String password = password_tv.getText().toString();

            if (username.equals("admin") && (password.equals("12345")))
            {
                Toast.makeText(TelaDeLogin.this, "Login realizado com sucesso", Toast.LENGTH_LONG).show();
                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                startActivity(intent);
            }else
            {
                Toast.makeText(TelaDeLogin.this, "Dados incorretos", Toast.LENGTH_SHORT).show();
        }
    });
    }


}

Its a very simple login activity
I’ve tried putting parentheses and braces everywhere, it must be something obvious but I can’t find it

enter image description here
enter image description here

>Solution :

put "}" after second Toast.makeText(…) line

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading