login.xml
Código
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:id="@+id/editTextUserNameToLogin" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="Usuario" > <requestFocus /> </EditText> <EditText android:id="@+id/editTextPasswordToLogin" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="Clave" android:inputType="textPassword" /> <CheckBox android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Recordar Datos" /> <Button android:id="@+id/buttonSignIn" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Aceptar" /> </LinearLayout>
HomeActivity.java
Código
package com.techblogon.loginexample; import android.app.Activity; import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class HomeActivity extends Activity { Button btnSignIn,btnSignUp; LoginDataBaseAdapter loginDataBaseAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); close_Button.setOnClickListener(new OnClickListener() { @Override finish(); } }); // create a instance of SQLite Database loginDataBaseAdapter=new LoginDataBaseAdapter(this); loginDataBaseAdapter=loginDataBaseAdapter.open(); // Get The Refference Of Buttons // Set OnClick Listener on SignUp button // TODO Auto-generated method stub /// Create Intent for SignUpActivity and Start The Activity Intent intentSignUP=new Intent(getApplicationContext(),SignUPActivity.class); startActivity(intentSignUP); } }); } // Methos to handleClick Event of Sign In Button { dialog.setContentView(R.layout.login); dialog.setTitle("Ingresar"); // get the Refferences of views final EditText editTextUserName=(EditText)dialog.findViewById(R.id.editTextUserNameToLogin); final EditText editTextPassword=(EditText)dialog.findViewById(R.id.editTextPasswordToLogin); // Set On ClickListener // get The User name and Password // fetch the Password form database for respective user name // check if the Stored password matches with Password entered by user if(password.equals(storedPassword)) { Toast.makeText(HomeActivity.this, "Ingreso Satifactorio", Toast.LENGTH_LONG).show(); dialog.dismiss(); } else { Toast.makeText(HomeActivity.this, "Usuario O Clave Erronea", Toast.LENGTH_LONG).show(); } } }); dialog.show(); } @Override protected void onDestroy() { super.onDestroy(); // Close The Database loginDataBaseAdapter.close(); } }
muchas gracias de antemano.