Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, 28 February 2018

login activity in xml file and java file for android

log in activity 



XML FILE ;




<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context="com.example.store.n01.login_Activity">

    <EditText
        android:id="@+id/edt_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="@drawable/text_box"
        android:hint="@string/email_or_username"
        android:inputType="textEmailAddress"
        android:padding="10dp"
        android:gravity="center"
        />

    <EditText
        android:id="@+id/edt_passward"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/edt_email"
        android:layout_alignStart="@+id/edt_email"
        android:layout_below="@+id/edt_email"
        android:layout_marginTop="25dp"
        android:background="@drawable/text_box"
        android:hint="@string/passward"
        android:inputType="textPassword"
        android:textAlignment="center"
        android:padding="10dp"/>

    <Button
        android:id="@+id/btn_login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/edt_passward"
        android:layout_alignStart="@+id/edt_passward"
        android:layout_below="@+id/edt_passward"
        android:layout_marginTop="43dp"
        android:background="@drawable/btn_all"
        android:textSize="18sp"
        android:text="@string/bt_login"
        android:gravity="center"
        android:padding="10dp"/>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/btn_login"
        android:layout_alignRight="@+id/btn_login"
        android:layout_below="@+id/btn_login"
        android:layout_marginEnd="21dp"
        android:layout_marginRight="21dp"
        android:layout_marginTop="16dp"
        android:text="@string/forget_passward" />
</android.widget.RelativeLayout>









PREVIEW OF XML FILE




java FILE :-

(in that file include all error massage for email
check out , password length ,intent press login button to sign_up activiety
toast make ,also)

package com.example.store.n01;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class login_Activity extends AppCompatActivity {

    EditText edt_email,edt_passward;
    Button btn_login;


    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login_);

        edt_email = (EditText)findViewById(R.id.edt_email);
        edt_passward= (EditText)findViewById(R.id.edt_passward);
        btn_login=(Button)findViewById(R.id.btn_login);

        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {

                if(checkEmail(edt_email,"Enter Valid Email") && checkpassward(edt_passward,"Enter 6 cherecter passward")) {

                    Intent i = new Intent(getApplicationContext(),Sign_up.class);
                    startActivity(i);


                   // String s1 = edt_email.getText().toString();                    //String s2 = edt_passward.getText().toString();
                    //oast.makeText(login_Activity.this, s1, Toast.LENGTH_SHORT).show();
                   // Toast.makeText(login_Activity.this, s2, Toast.LENGTH_SHORT).show();                }

               
            }
        });

    }

    public boolean checkEmail(EditText edt,String msg)
    {

        if(edt.getText().toString() != null && edt.getText().toString() != ""                && edt.getText().toString().length() > 0 && Patterns.EMAIL_ADDRESS.matcher(edt.getText().toString()).matches())
        {
            return true;
        }
        else{
            edt.setError(msg);
            return false;
        }
    }
    public boolean checkpassward(EditText edt,String msg)
    {

        if(edt.getText().toString() != null && edt.getText().toString() != ""                && edt.getText().toString().length() >= 6 )
        {
            return true;
        }
        else{
            edt.setError(msg);
            return false;
        }
    }
}

Tuesday, 27 February 2018

Button AND TEXT BOX for android drawable xml file

hello today

we introduce button layout xml file for colours and properties


xml file btm_all


<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:radius="17dp"        />
    <gradient
        android:angle="45"
        android:centerX="40%"
        android:centerColor="#f5e28c"
        android:startColor="#f9aaaa"
        android:endColor="#fc5454"
        android:type="linear"
        />
    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="15dp"
        />
    <size

        android:height="60dp"
        android:width="270dp"
        />
    <stroke
        android:width="3dp"
        android:color="#f7f4f4"
        />
</shape>




file location 

app>res>drawable

file name - btn_all







preview :-




for 


 apply button for that background 


         android:background="@drawable/btn_all"


add that property in Button code


TEXT BOX DRAWABLE xml file :


<?xml version="1.0"
 encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:radius="17dp"
        />
    <gradient
        android:angle="45"
        android:centerX="40%"
        android:centerColor="#fff9dd"
        android:startColor="#fff1f1"
        android:endColor="#ffdddd"
        android:type="linear"
        />
    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="15dp"
        />
    <size
        android:height="30dp"
        android:width="270dp"
        />
    <stroke
        android:width="3dp"
        android:color="#4b4b4b"
        />

</shape>

file location 
app>res>drawable
file name - text_box.xml





preview :-




apply text box for that background 


         android:background="@drawable/text_box"


add that property in text box code

B Remi Calculator

Loan Calculator Loan Calculator Loan Amount PF Cross Sell (LI % GI) No Yes EMI CARD No Ye...