Sun. Dec 22nd, 2024

activity_main.xml

<?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=".MainActivity"
    android:orientation="vertical"

    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Example Form"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"

         />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >

    <EditText
        android:id="@+id/editTextTextPersonName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:hint="textPersonName"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextTextPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword"
        android:hint="textPassword"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextNumberPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberPassword"
        android:hint="numberPassword"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextTextEmailAddress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress"
        android:hint="textEmailAddress"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextTextMultiLine"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:gravity="start|top"
        android:inputType="textMultiLine"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"
        android:hint="textMultiLine"
        android:minLines="10"/>

    <EditText
        android:id="@+id/editTextTextPostalAddress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPostalAddress"
        android:hint="textPostalAddress"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextTime"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="time"
        android:hint="time"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextNumber"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="number"
        android:hint="number"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextNumberSigned"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberSigned"
        android:hint="numberSigned"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

    <EditText
        android:id="@+id/editTextNumberDecimal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberDecimal"
        android:hint="numberDecimal"
        android:textColor="#E91E63"
        android:textSize="20sp"
        android:textStyle="italic"
        android:textAllCaps="true"
        android:layout_margin="5dp"
        android:padding="5dp"
        android:textColorHint="#3F51B5"/>

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/bt"
            android:text="Submit"></Button>
    </LinearLayout>
    </ScrollView>

</LinearLayout>

MainActivity.kt

package com.androinidan.form

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Toast

class MainActivity : AppCompatActivity() {

    var button: Button?=null
    var e1: EditText?=null
    var e2: EditText?=null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        button=findViewById(R.id.bt)
        e1=findViewById(R.id.editTextTextPersonName)
        e2=findViewById(R.id.editTextTextPassword)

        button!!.setOnClickListener {

            var s1: String= e1!!.text.toString()
            var s2: String=e2!!.text.toString()
            Toast.makeText(applicationContext,s1+s2,Toast.LENGTH_LONG).show()

        }
    }
}

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *