package com.msagroup.sbhmg; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class LogIn extends Activity { Button _gotousermain; EditText _etmail; EditText _etpassword; String _email; String _pass; TextView _tvcomm; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); _gotousermain = (Button) findViewById(R.id.btnlogin); _etmail = (EditText) findViewById(R.id.etmail); _etpassword = (EditText) findViewById(R.id.etpassword); _tvcomm = (TextView) findViewById(R.id.tvcomment); _gotousermain.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //startActivity(new Intent(LogIn.this, UserMain.class)); _email = _etmail.getText().toString(); _pass = _etpassword.getText().toString(); if(_email == "user@user.com" && _pass == "123") { startActivity(new Intent(LogIn.this, UserMain.class)); } else { if(_email == "admin@admin.com" && _pass == "123") { startActivity(new Intent(LogIn.this, AdminMain.class)); } else { _tvcomm.append("@string"); } } //} //catch (Exception e) { //} //finally //{ // //} } }); } }
<?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" > <EditText android:id="@+id/etmail" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="41dp" android:hint="@string/email" android:inputType="textEmailAddress" > <requestFocus /> </EditText> <EditText android:id="@+id/etpassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/etmail" android:layout_marginTop="16dp" android:hint="@string/password" android:inputType="textPassword" /> <Button android:id="@+id/btnlogin" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/etpassword" android:layout_marginTop="16dp" android:text="@string/login" /> <Button android:id="@+id/btnregistration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/btnlogin" android:layout_marginTop="70dp" android:text="@string/registration" /> <Button android:id="@+id/btnbacktomain" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/btnregistration" android:layout_alignBottom="@+id/btnregistration" android:layout_alignParentRight="true" android:text="@string/backtomain" /> <TextView android:id="@+id/tvcomment" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:text="@string/invalidlogin" android:visibility="invisible"/> </RelativeLayout>
if(_email.equals("user@user.com") && _pass.equals("123")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)