Showing posts with label studio. Show all posts
Showing posts with label studio. 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;
        }
    }
}

Monday, 26 February 2018

example android hello world

hello friends

today we study about our android fist example HELLO WORD ,

TO SHOW IN YOUR ANDROID PHONE  with example and setting up ANDROID STUDIO .

and also setting to your mobile to run application IN ANDROID  SMART PHONE



NOW WE START

1) SETTING UP STUDIO ,



  • REFER DOWNLOAD A JAVA UPDATE VERSION AND INSTALL IN YOUR PC OR LAPTOP .
  • GIVE PATH TO JAVA  follow link https://www.javatpoint.com/how-to-set-path-in-java


  • now download ANDROID STUDIO FROM GOOGLE ,PURIFIER NEW VERSION AT AVAILABLE IN THAT SITE  https://developer.android.com/studio/index.html
      

  • AFTER download run .it takes some time to download component so make sure to some passion , it take more than 1 hour ,


  • now start your android project with empty activity . 


EXAMPLE 


HELLO WORLD,




The Main Activity File

The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World! application −
package com.example.helloworld;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}

The Layout File

The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application. For your "Hello World!" application, this file will have following content related to default layout −
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >
   
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:padding="@dimen/padding_medium"
      android:text="@string/hello_world"
      tools:context=".MainActivity" />
      
</RelativeLayout>

Step by step:
  1. Connect your phone to computer via USB.
  2. Development option create by click on about phone> Kernel version (tap on that at list 8 time thane create a developer option . on your hend-set ) now time in a Mi and VIVO   phone not required to create option , it was automatic generated by  connect usb  to your system .
  3. Enable USB debugging on your phone: Settings -> Applications -> Development -> USB debugging.
  4. Change Run configuration in your Eclipse project: right click -> Run As -> Run Configuration




thank you

connect with us ,  comment section for more 
next section will be continue with some other example on android WIDGETS ,

B Remi Calculator

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