Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.com.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();
- }
- public void setPointer()
- {
- txtUser=(EditText)findViewById(R.id.user);
- txtPass=(EditText)findViewById(R.id.pass);
- }
- public void btnLogin(View v)
- {
- String chkUser = txtUser.getText().toString();
- String chkPass = txtPass.getText().toString();
- if(chkUser.toLowerCase().equals("oorya") && chkPass.toLowerCase().equals("12345"))
- Toast.makeText(this, "Hello "+chkUser, Toast.LENGTH_LONG).show();
- else
- Toast.makeText(this, "Wrong User", Toast.LENGTH_LONG).show();
- }
- }
- ================================================xml
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:gravity="center">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical"
- android:id="@+id/top"
- android:weightSum="1">
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:id="@+id/imageView"
- android:src="@drawable/hackeru"/>
- </LinearLayout>
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical"
- android:id="@+id/mid"
- android:gravity="center"
- android:weightSum="1">
- <EditText
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/enter_user"
- android:textSize="24sp"
- android:inputType="text"
- android:id="@+id/user"/>
- <EditText
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/enter_pass"
- android:textSize="24sp"
- android:inputType="textPassword"
- android:id="@+id/pass"
- android:layout_below="@+id/user"/>
- </RelativeLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical"
- android:id="@+id/bot"
- android:gravity="center">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Login"
- android:textSize="30dp"
- android:id="@+id/button"
- android:background="#8aa2bfdf"
- android:layout_gravity="center_horizontal"
- android:onClick="btnLogin"/>
- </LinearLayout>
- </LinearLayout>
- =============================================values
- <resources>
- <string name="app_name">My Login</string>
- <string name="action_settings">Settings</string>
- <string name="enter_user">Enter user name</string>
- <string name="enter_pass">Enter password</string>
- </resources>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement