Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main activity XML
- ===================
- <LinearLayout
- android:orientation="vertical"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/logo"/>
- </LinearLayout>
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:gravity="center">
- <EditText
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="text"
- android:hint="@string/enterUser"
- android:textSize="24sp"
- android:id="@+id/userName"
- android:gravity="center" />
- <EditText
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textPassword"
- android:hint="@string/enterPass"
- android:textSize="24sp"
- android:layout_below="@id/userName"
- android:id="@+id/userPass"
- android:gravity="center" />
- </RelativeLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:gravity="center">
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textSize="24sp"
- android:text="Login to system"
- android:onClick="btnLogin"/>
- </LinearLayout>
- </LinearLayout>
- mainActivity.java
- ======================
- package com.example.app0811.mylogin;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.EditText;
- import android.widget.Toast;
- public class MainActivity extends Activity
- {
- EditText txtUser;
- EditText txtPass;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- setPointer();
- }
- private void setPointer()
- {
- txtUser=(EditText)findViewById(R.id.userName);
- txtPass=(EditText)findViewById(R.id.userPass);
- }
- public void btnLogin(View v)
- {
- String chkUser= txtUser.getText().toString();
- String chkPass=txtPass.getText().toString();
- if (chkUser.toLowerCase().equals("eyob") && chkPass.equals("1234"))
- Toast.makeText(this,"Hello master....",Toast.LENGTH_LONG).show();
- else
- Toast.makeText(this,"Who are you???",Toast.LENGTH_LONG).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement