What are the leap year years? JAVA and XML Code Android Studio

Arah Lab
1

 





Check Leap Year - XML CODE

Android Studio Java Code Box with Copy Button
     
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    tools:context=".Lip_Year"
    android:orientation="vertical"
    android:background="#E4EEED"
    >

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar8"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@drawable/bottom_curved"
        app:title="কোন কোন সাল লিপ ইয়ার তা দেখুন!"
        android:elevation="4dp"
        app:titleTextColor="@color/white"
        />



    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/jamsed1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        app:errorTextColor="#FF0000"
        app:hintTextColor="#0038FF"
        android:hint="কত সাল থেকে লিপ ইয়ার সাল দেখতে চাও?"
        app:boxStrokeColor="#000DFF"
        android:textColorHint="@color/black"
        app:endIconMode="clear_text"
        app:endIconTint="#FF0000"
        >

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/edjamse1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="numberDecimal"
            android:textColor="@color/black"
            />


    </com.google.android.material.textfield.TextInputLayout>


    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/jamsed2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"
        app:errorTextColor="#FF0000"
        app:hintTextColor="#0038FF"
        android:hint="কত সাল পর্যন্ত লিপ ইয়ার সাল দেখতে চাও?"
        app:boxStrokeColor="#000DFF"
        android:textColorHint="@color/black"
        app:endIconMode="clear_text"
        app:endIconTint="#FF0000"
        >

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/edjamse2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="numberDecimal"
            android:textColor="@color/black"
            />


    </com.google.android.material.textfield.TextInputLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="2"
        android:layout_marginTop="10dp"
        >

        <Button
            android:id="@+id/Buttonjam"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="#1100FF"
            android:text="Click Here"
            android:textColor="#FFFFFF"
            android:textSize="20sp"
            android:layout_weight="1"
            android:layout_marginRight="110dp"
            android:layout_marginLeft="110dp"
            />




    </LinearLayout>


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="400dp"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_margin="20dp"
            >

            <TextView
                android:id="@+id/TVDisplayjam"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="25sp"
                android:textColor="@color/black"
                android:layout_marginLeft="40dp"
                android:layout_marginRight="40dp"
                android:visibility="gone"
                />

            <com.airbnb.lottie.LottieAnimationView
                android:id="@+id/AnimisonLottijam"
                android:layout_width="match_parent"
                android:layout_height="400dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.498"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                android:layout_gravity="center"
                app:lottie_autoPlay="true"
                app:lottie_loop="true"
                app:lottie_rawRes="@raw/search"
                android:visibility="visible"
                />


        </LinearLayout>

    </ScrollView>



</LinearLayout>


        


  Check Leap Year - JAVA CODE
Android Studio Java Code Box with Copy Button

package com.arah.jobayerahmed;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;

import com.airbnb.lottie.LottieAnimationView;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;

public class Lip_Year extends AppCompatActivity {
    TextInputEditText edjamse1, edjamse2;
    Button Buttonjam;
    TextView TVDisplayjam;
    TextInputLayout jamsed1, jamsed2;
    Animation Lipa1,Lipa2, Lipa3;
    LottieAnimationView AnimisonLottijam;


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

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar8);
        setSupportActionBar(toolbar);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }

        edjamse1 = findViewById(R.id.edjamse1);
        edjamse2 = findViewById(R.id.edjamse2);
        Buttonjam = findViewById(R.id.Buttonjam);
        TVDisplayjam = findViewById(R.id.TVDisplayjam);

        jamsed1 = findViewById(R.id.jamsed1);
        jamsed2 = findViewById(R.id.jamsed2);
        AnimisonLottijam = findViewById(R.id.AnimisonLottijam);



        Lipa1 = AnimationUtils.loadAnimation(this, R.anim.home1);
        Lipa2 = AnimationUtils.loadAnimation(this, R.anim.home3);
        Lipa3 = AnimationUtils.loadAnimation(this, R.anim.home1);

        jamsed1.setAnimation(Lipa1);
        jamsed2.setAnimation(Lipa2);
        Buttonjam.setAnimation(Lipa3);




        Buttonjam.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TVDisplayjam.setText("লিপ ইয়ার সাল গুলো হলো");

                String Jobayer1 = edjamse1.getText().toString();
                String Jobayer2 = edjamse2.getText().toString();

                if (Jobayer1.isEmpty()){
                    edjamse1.setError("Enter Number");
                }else if (Jobayer2.isEmpty()) {
                    edjamse2.setError("Enter Number");
                }else {

                    long Eb1 = Long.parseLong(Jobayer1);
                    long Eb2 = Long.parseLong(Jobayer2);


                    for (int J = (int) Eb1; J<=Eb2; J++){

                        if ((J%400==0) || (J%4==0 && J%100!=0 )){

                            AnimisonLottijam.setVisibility(View.GONE);
                            TVDisplayjam.setVisibility(View.VISIBLE);
                            TVDisplayjam.append(" "+J);
                        }

                    }


                }



            }
        });


    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }


}

        

Post a Comment

1Comments

Post a Comment