Following is the Sample Android Login Application which I have developed and would like to share with everyone.
This Application is at its very basic stage, Irrespective of the database used.
It works as follows:
If User Name and Password Entered are similar it gives a Toast pop up saying that "Login Successful"
Else It will give a Toast pop up Saying that "Invalid Login"
I feel it will help the Android learning beginners:
This application is developed on Following platforms:
Ubuntu 10.10,
Eclipse 3.5 Galileo
Android 2.1 SDK
Following is the Screen short of the Application:
Following is the Screen short of the Application:
I have used Table Layout, Following is the Layout Code for the Same:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="User Name: "
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:text=""
android:id="@+id/txtUname"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
</TableRow>
<TableRow>
<TextView
android:text="Password: "
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText
android:text=""
android:id="@+id/txtPwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:password="true">
</EditText>
</TableRow>
<TableRow>
<Button
android:text="Cancel"
android:id="@+id/btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
<Button
android:text="Login"
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</TableRow>
</TableLayout>
Following is the Activity Code for the Application:
package com.mayuri.login;
import android.app.Activity;
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 SampleLogin extends Activity {
EditText txtUserName;
EditText txtPassword;
Button btnLogin;
Button btnCancel;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtUserName=(EditText)this.findViewById(R.id.txtUname);
txtPassword=(EditText)this.findViewById(R.id.txtPwd);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
Toast.makeText(SampleLogin.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(SampleLogin.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}
}
Following are the Screenshots of the Applications, Depending on their behaviours i.e. "Login Success" and "Invalid Login".
I hope this example proves to be useful to the people learning Android.
I will keep on updating with more and more examples.
~Mayuri
Best Car pool Android Application Best Car Pool Application Source Code Download Here
Best Social Network Cordova Ionic Application Best Social Networking Source Code Cordova Ioinc Application Download Here
Best Android Application, Android Restaurant System Best Android Restaurant Application Source code download here
Best Android Application Android Chat Source code download Android Chat Source code download
Best Android Quiz Source Code Download Best Android Quiz Source Code Download here
More and Lots of useful Android source codes here Best Android Source codes download here


