Blog purpose for android basic example for android app developer. any query please my contact

Wednesday, 17 February 2021

kotlin login page example in android

 kotlin login page example in android

In this Article today Learn kotlin login page example in android. Kotlin is a Programming Langauge Since a 2017 It is Use By Develop a Android Application. Follow the Full Source Code kotlin login page example in android. for more information visit https://developer.android.com/codelabs/advanced-android-kotlin-training-login


1.Login.kt:

package com.akash.kotlinlistview

import android.app.Activity

import android.os.Bundle

import android.view.View

import android.widget.*

class Login : Activity() {


    override fun onCreate(savedInstanceState: Bundle?) {

        super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_login)


        // get reference to all views

        var et_user_name = findViewById(R.id.et_user_name) as EditText

        var et_password = findViewById(R.id.et_password) as EditText

        var btn_reset = findViewById(R.id.btn_reset) as Button

        var btn_submit = findViewById(R.id.btn_submit) as Button


        btn_reset.setOnClickListener {

            // clearing user_name and password edit text views on reset button click

            et_user_name.setText("")

            et_password.setText("")

        }


        // set on-click listener

        btn_submit.setOnClickListener {

            val user_name = et_user_name.text;

            val password = et_password.text;

            Toast.makeText(this@Login, user_name, Toast.LENGTH_LONG).show()


            // your code to validate the user_name and password combination

            // and verify the same


        }

    }

}



2.activity_login.xml:

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout 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=".Login">

    <LinearLayout

        android:id="@+id/ll_main_layout"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:gravity="center"

        android:background="#444444"

        android:padding="25dp"

        android:orientation="vertical">

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:textSize="25dp"

            android:textColor="#6dffbf"

            android:padding="30dp"

            android:text="Login"/>

        <EditText

            android:id="@+id/et_user_name"

            android:hint="User Name"

            android:textColor="#6bfff7"

            android:textColorHint="#52afaa"

            android:textAlignment="center"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"/>

        <EditText

            android:id="@+id/et_password"

            android:hint="Password"

            android:textColor="#6bfff7"

            android:textColorHint="#52afaa"

            android:textAlignment="center"

            android:inputType="textPassword"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"/>

        <LinearLayout

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:gravity="center"

            android:padding="25dp"

            android:orientation="horizontal">

            <Button

                android:id="@+id/btn_reset"

                android:text="Reset"

                android:textAllCaps="false"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content" />

            <Button

                android:id="@+id/btn_submit"

                android:text="Submit"

                android:textAllCaps="false"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content" />

        </LinearLayout>

    </LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout>


3.AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.akash.kotlinlistview">


    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"

        android:label="@string/app_name"

        android:roundIcon="@mipmap/ic_launcher_round"

        android:supportsRtl="true"

        android:theme="@style/AppTheme">

        <activity android:name=".Login">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest>


4.styles.xml:

<resources>

    <!-- Base application theme. -->

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

        <!-- Customize your theme here. -->

        <item name="colorPrimary">@color/colorPrimary</item>

        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>

        <item name="colorAccent">@color/colorAccent</item>

    </style>

</resources>


5.colors.xml:

<?xml version="1.0" encoding="utf-8"?>

<resources>

    <color name="colorPrimary">#6200EE</color>

    <color name="colorPrimaryDark">#3700B3</color>

    <color name="colorAccent">#03DAC5</color>

</resources>


6.strings.xml:

<resources>

    <string name="app_name">kotlin login</string>

</resources>


7.Output:

kotlin login page example in android




No comments:

Post a Comment