Untitled
unknown
plain_text
a month ago
1.5 kB
4
Indexable
Never
package com.example.myapplication; 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 MainActivity extends AppCompatActivity implements View.OnClickListener{ static final String username = "text"; static final String password = "hello"; Button lbutton; EditText uname; EditText upass; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lbutton = findViewById(R.id.button); uname = findViewById(R.id.editTextText); upass = findViewById(R.id.editTextText2); lbutton.setOnClickListener(this); Button press_button = findViewById(R.id.button); press_button.setOnClickListener(this); } public void onClick(View view) { if (uname.getText().toString().equals(username) && upass.getText().toString().equals(password)) { Toast.makeText(this, "Login Success", Toast.LENGTH_LONG).show(); Intent next; next = new Intent(MainActivity.this, MainActivity2.class); startActivity(next); } else Toast.makeText(this, "Login Failed", Toast.LENGTH_LONG).show(); } }
Leave a Comment