npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

endmad26

v1.0.0

Published

BMS College of Engineering Mail Syed Saifullah Beigh <[email protected]> (no subject) Syed Saifullah Beigh <[email protected]> Sun, Jun 29, 2025 at 11:18 PM To: Vyom Goyal <[email protected]>, Syed Saifullah Beigh <saifulla

Downloads

1

Readme

BMS College of Engineering Mail Syed Saifullah Beigh [email protected] (no subject) Syed Saifullah Beigh [email protected] Sun, Jun 29, 2025 at 11:18 PM To: Vyom Goyal [email protected], Syed Saifullah Beigh [email protected], Kumar Aditya [email protected], Nilesh Kumar Singh [email protected] CIE 1

Autocomplete

XML

<AutoCompleteTextView
    android:id="@+id/autoCompleteTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Type a fruit" />

<AutoCompleteTextView
    android:id="@+id/autoCompleteTextView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Type a colour"
    android:layout_marginTop="16dp" />

package com.example.myapplication

import android.annotation.SuppressLint import android.os.Bundle import android.widget.ArrayAdapter import android.widget.AutoCompleteTextView import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

private val fruits = arrayOf("Apple", "Banana")
private val colours = arrayOf("Blue", "Purple")

@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val autoTextView: AutoCompleteTextView = findViewById(R.id.autoCompleteTextView)
    val autoTextView2: AutoCompleteTextView = findViewById(R.id.autoCompleteTextView2)

    val adapter1: ArrayAdapter<String> = ArrayAdapter(
        this,
        android.R.layout.select_dialog_item,
        fruits
    )

    val adapter2: ArrayAdapter<String> = ArrayAdapter(
        this,
        android.R.layout.select_dialog_item,
        colours
    )

    autoTextView.threshold = 1
    autoTextView.setAdapter(adapter1)

    autoTextView2.threshold = 1
    autoTextView2.setAdapter(adapter2)
}

}







DatePicker

<DatePicker
    android:id="@+id/element1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="30dp"
    android:layout_marginTop="150dp"
    android:layout_marginEnd="31dp"
    android:layout_marginBottom="150dp" />

package com.example.test1

import android.os.Build import android.os.Bundle import android.support.annotation.RequiresApi import android.support.v7.app.AppCompatActivity import android.widget.DatePicker import android.widget.Toast

@Suppress("NAME_SHADOWING") class MainActivity : AppCompatActivity() { @RequiresApi(Build.VERSION_CODES.O) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val picker1=findViewById(R.id.element1) picker1.setOnDateChangedListener { picker1, i, i2, i3 -> val i2 = i2 + 1 Toast.makeText(applicationContext,"Date is: $i3/$i2/$i",Toast.LENGTH_SHORT).show() }

}

}







ToggleButton

<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"
    android:layout_marginTop="50dp"
    android:src="@drawable/ic_launcher_background" />

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imageView"
    android:layout_centerInParent="true"
    android:layout_marginTop="50dp"
    android:text="TextView" />

<ToggleButton
    android:id="@+id/toggleButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView"
    android:layout_centerInParent="true"
    android:layout_marginTop="50dp"
    android:text="ToggleButton" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"
    android:layout_marginTop="50dp"
    app:srcCompat="@drawable/img" />

package com.example.test1

import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.ImageView import android.widget.TextView import android.widget.ToggleButton

class MainActivity : AppCompatActivity() { lateinit var image1: ImageView lateinit var image2: ImageView lateinit var result: TextView lateinit var toggleButton: ToggleButton override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main)

    toggleButton=findViewById(R.id.toggleButton)
    image1=findViewById(R.id.imageView)
    image2=findViewById(R.id.imageView2)
    result=findViewById(R.id.textView)

    toggleButton.setOnCheckedChangeListener { compoundButton,isChecked->
        if(isChecked){
            image1.visibility = View.VISIBLE
            image2.visibility = View.GONE
            result.text="Image1 is visible"
        }
        else{
            image1.visibility = View.GONE
            image2.visibility = View.VISIBLE
            result.text="Image2 is visible"
        }
    }
}

}







Calculator

<android.support.constraint.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=".MainActivity">

<EditText
    android:id="@+id/editTextNumber1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:hint="Enter number 1"
    android:inputType="number"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    android:layout_marginTop="32dp"
    android:ems="10" />

<EditText
    android:id="@+id/editTextNumber2"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:hint="Enter number 2"
    android:inputType="number"
    app:layout_constraintTop_toBottomOf="@+id/editTextNumber1"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="16dp"
    android:ems="10" />

<TextView
    android:id="@+id/result"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Result"
    app:layout_constraintTop_toBottomOf="@+id/editTextNumber2"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="16dp" />

<Button
    android:id="@+id/buttonsubs"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sub"
    app:layout_constraintTop_toBottomOf="@+id/result"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="16dp" />

<Button
    android:id="@+id/buttonadd"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Add"
    app:layout_constraintTop_toBottomOf="@+id/buttonsubs"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="16dp" />

<Button
    android:id="@+id/buttondiv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Div"
    app:layout_constraintTop_toBottomOf="@+id/buttonadd"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="16dp" />

<Button
    android:id="@+id/buttonmult"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Mult"
    app:layout_constraintTop_toBottomOf="@+id/buttondiv"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="16dp" />

</android.support.constraint.ConstraintLayout>


package com.example.test2

import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.widget.Button import android.widget.EditText import android.widget.TextView

class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main)

    val buttonadd = findViewById<Button>(R.id.buttonadd)
    val buttonsubs = findViewById<Button>(R.id.buttonsubs)
    val buttonmult = findViewById<Button>(R.id.buttonmult)
    val buttondiv = findViewById<Button>(R.id.buttondiv)

    val number1 = findViewById<EditText>(R.id.editTextNumber1)
    val number2 = findViewById<EditText>(R.id.editTextNumber2)
    val answer = findViewById<TextView>(R.id.result)

    buttonadd.setOnClickListener{
        val num1 = number1.text.toString().toInt()
        val num2 = number2.text.toString().toInt()
        val sum = num1 + num2
        answer.text = sum.toString()
    }

    buttonsubs.setOnClickListener{
        val num1 = number1.text.toString().toInt()
        val num2 = number2.text.toString().toInt()
        val sum = num1 - num2
        answer.text = sum.toString()
    }

    buttonmult.setOnClickListener{
        val num1 = number1.text.toString().toInt()
        val num2 = number2.text.toString().toInt()
        val sum = num1 * num2
        answer.text = sum.toString()
    }

    buttondiv.setOnClickListener{
        val num1 = number1.text.toString().toInt()
        val num2 = number2.text.toString().toInt()
        val sum = num1 / num2
        answer.text = sum.toString()
    }

}

}







CHECKBOX -> PIZZAAA

XML

<android.support.constraint.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=".MainActivity">

<CheckBox
    android:id="@+id/checkBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Pizza - 100 Rs"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_marginTop="48dp"
    android:layout_marginStart="32dp" />

<CheckBox
    android:id="@+id/checkBox2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Coffee - 50 Rs"
    app:layout_constraintTop_toBottomOf="@id/checkBox"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_marginTop="16dp"
    android:layout_marginStart="32dp" />

<CheckBox
    android:id="@+id/checkBox3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Burger - 120 Rs"
    app:layout_constraintTop_toBottomOf="@id/checkBox2"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_marginTop="16dp"
    android:layout_marginStart="32dp" />

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Show Bill"
    app:layout_constraintTop_toBottomOf="@id/checkBox3"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_marginTop="32dp"
    android:layout_marginStart="32dp" />

</android.support.constraint.ConstraintLayout>



package com.example.myapplication

import android.annotation.SuppressLint import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.widget.*

class MainActivity : AppCompatActivity() { lateinit var pizza: CheckBox lateinit var coffee: CheckBox lateinit var burger: CheckBox lateinit var button: Button

@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    pizza = findViewById(R.id.checkBox)
    coffee = findViewById(R.id.checkBox2)
    burger = findViewById(R.id.checkBox3)
    button = findViewById(R.id.button)

    button.setOnClickListener {
        var totalAmount = 0
        val result = StringBuilder()
        result.append("Selected Items:\n")

        if (pizza.isChecked) {
            result.append("Pizza: 100 Rs\n")
            totalAmount += 100
        }

        if (coffee.isChecked) {
            result.append("Coffee: 50 Rs\n")
            totalAmount += 50
        }

        if (burger.isChecked) {
            result.append("Burger: 120 Rs\n")
            totalAmount += 120
        }

        result.append("Total: $totalAmount Rs")
        Toast.makeText(applicationContext, result.toString(), Toast.LENGTH_LONG).show()
    }
}

}


Donut Code Toast

<android.support.constraint.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=".MainActivity">

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_marginTop="48dp"
    android:onClick="donuts"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:srcCompat="@drawable/img" />

<ImageView
    android:id="@+id/imageView8"
    android:layout_width="190dp"
    android:layout_height="195dp"
    android:layout_marginTop="4dp"
    android:onClick="froyo"
    app:layout_constraintTop_toBottomOf="@id/imageView5"
    app:layout_constraintStart_toStartOf="parent"
    app:srcCompat="@drawable/img" />

<ImageView
    android:id="@+id/imageView7"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_marginTop="4dp"
    android:onClick="sandwich"
    app:layout_constraintTop_toBottomOf="@id/imageView8"
    app:layout_constraintStart_toStartOf="parent"
    app:srcCompat="@drawable/img" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Tap an item to order!"
    android:textSize="18sp"
    android:textStyle="bold"
    android:layout_marginTop="16dp"
    app:layout_constraintTop_toBottomOf="@id/imageView7"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent" />

</android.support.constraint.ConstraintLayout>


package com.example.myapplication

import android.annotation.SuppressLint import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.*

class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) }

fun donuts(view: View) {
    Toast.makeText(this, "You ordered Donuts", Toast.LENGTH_SHORT).show()
}

fun froyo(view: View) {
    Toast.makeText(this, "You ordered Froyo", Toast.LENGTH_SHORT).show()
}

fun sandwich(view: View) {
    Toast.makeText(this, "You ordered Sandwich", Toast.LENGTH_SHORT).show()
}

}

TimePicker

<android.support.constraint.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=".MainActivity">

<TimePicker
    android:id="@+id/tp1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="30dp"
    android:layout_marginTop="150dp"
    android:layout_marginEnd="31dp"
    android:layout_marginBottom="150dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent" />

</android.support.constraint.ConstraintLayout>


package com.example.test3

import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.widget.TimePicker import android.widget.Toast

@Suppress("NAME_SHADOWING") class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val tp=findViewById(R.id.tp1) tp.setOnTimeChangedListener{_,hour,minute-> val am_pm="" val hour=if(hour<10) "0" + hour else hour val min=if(minute<10) "0" +minute else minute val msg="Time is: + $hour : $min $am_pm" Toast.makeText(this@MainActivity,msg,Toast.LENGTH_SHORT).show() }

}

}



CUSTOM CHECKBOX FLOWER

XMLLL

<android.support.constraint.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=".MainActivity">

<LinearLayout
    android:id="@+id/option1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="150dp">

    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:src="@drawable/img" />

    <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="CheckBox 1"
        android:layout_marginStart="8dp"/>
</LinearLayout>

<LinearLayout
    android:id="@+id/option2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    app:layout_constraintTop_toBottomOf="@id/option1"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="30dp">

    <ImageView
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:src="@drawable/img" />

    <CheckBox
        android:id="@+id/checkBox2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="CheckBox 2"
        android:layout_marginStart="8dp"/>
</LinearLayout>

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Submit"
    app:layout_constraintTop_toBottomOf="@id/option2"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginTop="50dp" />

</android.support.constraint.ConstraintLayout>


package com.example.myapplication

import android.annotation.SuppressLint import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.view.View import android.widget.*

class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main)

    val button = findViewById<Button>(R.id.button)
    val ch1 = findViewById<CheckBox>(R.id.checkBox)
    val ch2 = findViewById<CheckBox>(R.id.checkBox2)

    button.setOnClickListener {
        val msg = StringBuilder("Selected: ")
        if (ch1.isChecked) {
            msg.append(" ${ch1.text}")
        }
        if (ch2.isChecked) {
            msg.append(" ${ch2.text}")
        }

        Toast.makeText(applicationContext, msg.toString(), Toast.LENGTH_LONG).show()
    }
}

}


Custom Toast

activity.xml:

<ImageView
    android:id="@+id/toast_icon"
    android:src="@drawable/img"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_marginEnd="8dp" />

<TextView
    android:id="@+id/toast_text"
    android:text="Custom Toast!"
    android:textColor="@android:color/white"
    android:textSize="16sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

toast_custom.xml:

<ImageView
    android:id="@+id/toast_icon"
    android:src="@drawable/img"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_marginEnd="8dp" />

<TextView
    android:id="@+id/toast_text"
    android:text="Custom Toast!"
    android:textColor="@android:color/white"
    android:textSize="16sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

kt file:

package com.example.test1

import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.view.Gravity import android.view.LayoutInflater import android.widget.TextView import android.widget.Toast

class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main)

    showCustomToast("Toast Test!")
}

private fun showCustomToast(message: String) {
    val inflater = layoutInflater
    val layout = inflater.inflate(R.layout.toast_custom, null)

    val textView = layout.findViewById<TextView>(R.id.toast_text)
    textView.text = message

    val toast = Toast(applicationContext)
    toast.view = layout
    toast.duration = Toast.LENGTH_SHORT
    toast.setGravity(Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0, 100)
    toast.show()
}

}


LoginSingup

<EditText
    android:id="@+id/editTextUsername"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Username"
    android:inputType="text" />

<EditText
    android:id="@+id/editTextPassword"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Password"
    android:inputType="textPassword" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="16dp">

    <Button
        android:id="@+id/buttonLogin"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="LOGIN" />

    <Button
        android:id="@+id/buttonSignup"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="SIGNUP" />

</LinearLayout>

package com.example.test1

import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.widget.Button import android.widget.EditText import android.widget.Toast

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val usernameEditText = findViewById<EditText>(R.id.editTextUsername)
    val passwordEditText = findViewById<EditText>(R.id.editTextPassword)
    val loginButton = findViewById<Button>(R.id.buttonLogin)

    loginButton.setOnClickListener {
        val enteredUsername = usernameEditText.text.toString()
        val enteredPassword = passwordEditText.text.toString()

        if (enteredUsername == "vyom" && enteredPassword == "goyal") {
            Toast.makeText(this, "Login Successful", Toast.LENGTH_SHORT).show()
            // You can add code here to navigate to the next screen or perform other actions
        } else {
            Toast.makeText(this, "Invalid Credentials", Toast.LENGTH_SHORT).show()
        }
    }

    val signupButton = findViewById<Button>(R.id.buttonSignup)
    signupButton.setOnClickListener {
        Toast.makeText(this, "Signup functionality to be implemented", Toast.LENGTH_SHORT).show()
        // Implement your signup logic here
    }
}

}


Radio Button:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="RadioGroup in Kotlin"
    android:textSize="20sp"
    android:textStyle="bold"
    android:layout_marginBottom="16dp" />

<RadioGroup
    android:id="@+id/radioGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RadioButton
        android:id="@+id/radioButtonOption1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Option 1" />

    <RadioButton
        android:id="@+id/radioButtonOption2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Option 2" />

    <RadioButton
        android:id="@+id/radioButtonOption3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Option 3" />

</RadioGroup>

<Button
    android:id="@+id/submitButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="SUBMIT"
    android:layout_marginTop="16dp" />

package com.example.test1

import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.widget.Button import android.widget.RadioButton import android.widget.RadioGroup import android.widget.Toast

class MainActivity : AppCompatActivity() {

lateinit var radioGroup: RadioGroup
lateinit var submitButton: Button

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    title = "RadioGroup in Kotlin" // Setting the title from the Kotlin code

    radioGroup = findViewById(R.id.radioGroup)
    submitButton = findViewById(R.id.submitButton)

    submitButton.setOnClickListener {
        val selectedOptionId = radioGroup.checkedRadioButtonId
        if (selectedOptionId != -1) {
            val selectedRadioButton = findViewById<RadioButton>(selectedOptionId)
            Toast.makeText(this, "Selected: ${selectedRadioButton.text}", Toast.LENGTH_SHORT).show()
        } else {
            Toast.makeText(this, "Please select an option", Toast.LENGTH_SHORT).show()
        }
    }
}

}


Spinner:

activity_main.xml:

<TextView
    android:id="@+id/result"
    android:layout_width="300dp"
    android:layout_height="50dp"
    android:background="#E91E63"
    android:gravity="center"
    android:text="TextView"
    android:textColor="#FFFFFF"
    android:textSize="20sp" />

<Spinner
    android:id="@+id/spinnerCountry"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp" />

string.xml in values folder:

MainActivity.kt:

package com.example.semend1

import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.Spinner import android.widget.TextView

class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {

lateinit var spinner : Spinner
lateinit var result : TextView

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    spinner = findViewById(R.id.spinnerCountry)
    result = findViewById(R.id.result)

    spinner.onItemSelectedListener = this

    var arrayAdapter = ArrayAdapter.createFromResource(
        this,
        R.array.countries,
        android.R.layout.simple_spinner_item
    )

    arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)

    spinner.adapter = arrayAdapter
}

override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
    if (parent != null) {
        result.text = parent.getItemAtPosition(position).toString()
    }
}

override fun onNothingSelected(p0: AdapterView<*>?) {

}

}


CIE 2

AlertDialog:

main.kt:

class MainActivity : AppCompatActivity() {

// Lateinit keyword means this variable will be initialized later, before use.
lateinit var showDialogMessage : Button

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    // Sets the content view to the layout defined in activity_main.xml
    setContentView(R.layout.activity_main)

    // Find the button by its ID from the layout
    showDialogMessage = findViewById(R.id.buttonDialogMessage)

    // Set an OnClickListener for the button
    showDialogMessage.setOnClickListener {
        // Call the function to show the AlertDialog when the button is clicked
        showAlertDialog()
    }
}

/**
 * Function to display an AlertDialog.
 * It prompts the user if they want to change the button's text.
 */
fun showAlertDialog() {
    // Create an instance of AlertDialog.Builder
    val alertDialog = AlertDialog.Builder(this@MainActivity)

    // Set the title of the dialog
    alertDialog.setTitle("Change")
        // Set the message of the dialog
        .setMessage("Do you want to change the text of the button?")
        // Set an icon for the dialog.
        // Using a default Android system icon as 'R.drawable.warning' might not exist by default.
        // If you have a custom 'warning.png' or 'warning.xml', place it in 'res/drawable'.
        .setIcon(android.R.drawable.ic_dialog_alert)
        // Set whether the dialog can be cancelled by touching outside it or pressing back button
        .setCancelable(false)
        // Set the Negative button (e.g., "No") and its click listener
        .setNegativeButton("No", DialogInterface.OnClickListener {
                dialogInterface, which ->
            // Dismiss the dialog when "No" is clicked
            dialogInterface.cancel()
            Toast.makeText(this, "Button text not changed.", Toast.LENGTH_SHORT).show()
        })
        // Set the Positive button (e.g., "Yes") and its click listener
        .setPositiveButton("Yes", DialogInterface.OnClickListener {
                dialogInterface, which ->
            // Change the text of the button to "Alert Dialog" when "Yes" is clicked
            showDialogMessage.text = "Alert Dialog"
            Toast.makeText(this, "Button text changed to 'Alert Dialog'.", Toast.LENGTH_SHORT).show()
        })

    // Create the AlertDialog object and show it
    alertDialog.create().show()
}

}

xml:

<android.support.constraint.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:id="@+id/myLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">

<Button
    android:id="@+id/buttonDialogMessage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Show Dialog Message"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>


ProgressBar:

kt file:

import android.os.Bundle import android.os.Handler import android.os.Looper // Import Looper for Handler import android.view.View import android.widget.Button import android.widget.ProgressBar import android.widget.TextView import android.support.v7.app.AppCompatActivity // Using android.support.v7.app.AppCompatActivity as requested

class MainActivity : AppCompatActivity() {

private var progressBar: ProgressBar? = null
private var i = 0
private var txtView: TextView? = null
// Initialize Handler with Looper.getMainLooper() for UI thread operations
private val handler = Handler(Looper.getMainLooper())

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    // Finding progressbar by its id and casting it to ProgressBar
    progressBar = findViewById<ProgressBar>(R.id.progress_Bar)

    // Finding textview by its id
    txtView = findViewById<TextView>(R.id.text_view)

    // Finding button by its id
    val btn = findViewById<Button>(R.id.show_button)

    // Handling click on button
    btn.setOnClickListener {
        // Before clicking the button, the progress bar will be invisible,
        // so we have to change the visibility of the progress bar to visible.
        progressBar!!.visibility = View.VISIBLE
        i = progressBar!!.progress // Get current progress (should be 0 initially)

        // Start a new thread for the progress simulation to avoid blocking the UI thread
        Thread(Runnable {
            // This loop will run until the value of i becomes 99
            while (i < 100) {
                i += 1
                // Update the progress bar and display the current value on the UI thread
                handler.post(Runnable {
                    progressBar!!.progress = i
                    // Setting current progress to the textview
                    txtView!!.text = "${i}/${progressBar!!.max}"
                })
                try {
                    // Pause the thread to simulate work
                    Thread.sleep(100)
                } catch (e: InterruptedException) {
                    e.printStackTrace()
                }
            }
            // After the loop, set the visibility of the progressbar to invisible on the UI thread
            handler.post {
                progressBar!!.visibility = View.INVISIBLE
                txtView!!.text = "Progress Complete!" // Optional: show completion message
            }
        }).start() // Start the new thread
    }
}

}

xml file:

<ProgressBar
    android:id="@+id/progress_Bar"
    style="?android:attr/progressBarStyle"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:indeterminate = "true"
    android:max="100"
    android:minWidth="200dp"
    android:minHeight="50dp"
    android:progress="0"
    android:visibility="invisible" />

<TextView
    android:id="@+id/text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/progress_Bar"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="16dp" />

<Button
    android:id="@+id/show_button"
    android:layout_width="191dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/text_view"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="Progress Bar" />

Canvas:

kt:

import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.ShapeDrawable import android.graphics.drawable.shapes.OvalShape import android.graphics.drawable.shapes.RectShape import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.widget.ImageView

class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val bitmap: Bitmap = Bitmap.createBitmap(700, 1000, Bitmap.Config.ARGB_8888) val canvas: Canvas = Canvas(bitmap) var shapeDrawable: ShapeDrawable // rectangle positions var left = 100 var top = 100 var right = 600 var bottom = 400

// draw rectangle shape to canvas shapeDrawable = ShapeDrawable(RectShape()) shapeDrawable.setBounds( left, top, right, bottom) shapeDrawable.getPaint().setColor(Color.parseColor("#009944")) shapeDrawable.draw(canvas) // draw oval shape to canvas shapeDrawable = ShapeDrawable(OvalShape()) shapeDrawable.setBounds( 100, 500, 600, 800) shapeDrawable.getPaint().setColor(Color.parseColor("#009191")) shapeDrawable.draw(canvas) val iv = findViewById(R.id.imageV) // now bitmap holds the updated pixels // set bitmap as background to ImageView

    val pCircle = Paint()
    pCircle.setColor(Color.BLACK)
    canvas.drawCircle(30f, 30f, 30f, pCircle)
    val pBackground = Paint()
    pBackground.color = Color.RED
    canvas.drawRect(450f, 450f, 500f, 500f, pBackground)
    iv.background = BitmapDrawable(getResources(), bitmap)
}

}

xml:

<android.support.constraint.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=".MainActivity">

<ImageView
    android:id="@+id/imageV"
    android:layout_width="315dp"
    android:layout_height="526dp"
    android:layout_marginTop="100dp"
    android:layout_marginEnd="50dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>


animation:

mainxml:

<TextView
    android:id="@+id/textView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/linearLayout"
    android:gravity="center"
    android:text="Mobile Application Development"
    android:textSize="32sp"
    android:textColor="@color/teal_200"
    android:textStyle="bold" />

<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <Button
            android:id="@+id/fade_in"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Fade In"
            android:textAllCaps="false" />

        <Button
            android:id="@+id/fade_out"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Fade Out"
            android:textAllCaps="false" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <Button
            android:id="@+id/zoom_in"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Zoom In"
            android:textAllCaps="false" />

        <Button
            android:id="@+id/zoom_out"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Zoom Out"
            android:textAllCaps="false" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <Button
            android:id="@+id/slide_down"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Slide Down"
            android:textAllCaps="false" />

        <Button
            android:id="@+id/slide_up"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Slide Up"
            android:textAllCaps="false" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <Button
            android:id="@+id/bounce"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Bounce"
            android:textAllCaps="false" />

        <Button
            android:id="@+id/rotate"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Rotate"
            android:textAllCaps="false" />
    </LinearLayout>

</LinearLayout>

res -> new -> android resource directory -> type= anim add new animation resource file

bounce.xml:

fad_in.xml:

fade_out.xml:

slide_down.xml:

slide_up.xml:

zoom_in.xml:

zoom_out.xml:

main kt.file

import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.view.animation.AnimationUtils import android.widget.Button import android.widget.TextView

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val textView = findViewById<TextView>(R.id.textView)

    findViewById<Button>(R.id.fade_in).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.fad_in)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.fade_out).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.fade_out)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.zoom_in).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.zoom_in)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.zoom_out).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.zoom_out)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.slide_up).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.slide_up)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.slide_down).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.slide_down)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.bounce).setOnClickListener {
        val animation = AnimationUtils.loadAnimation(this, R.anim.bounce)
        textView.startAnimation(animation)
    }

    findViewById<Button>(R.id.rotate).setOnClickListener {
        textView.animate().apply {
            duration = 1000
            rotationXBy(360f)
        }.start()
    }
}

}


contextMenu

activitymain.xml:

<android.support.constraint.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=".MainActivity">

<Button
    android:id="@+id/B1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Context Menu"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

java>new menu directory>new menu resource file named "menu_main.xml"

menu_main.xml:

main.kt:

import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.support.v7.widget.PopupMenu import android.view.ContextMenu import android.view.Menu import android.view.MenuItem import android.view.View import android.widget.Button import android.widget.Toast

class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val B1 = findViewById(R.id.B1) registerForContextMenu(B1) B1.setOnClickListener { v -> openContextMenu(v)} } override fun onCreateContextMenu( menu: ContextMenu?, v: View?, menuInfo: ContextMenu.ContextMenuInfo? ) { super.onCreateContextMenu(menu, v, menuInfo) menuInflater.inflate(R.menu.menu_main,menu) } override fun onContextItemSelected(item: MenuItem): Boolean { when (item.itemId){ R.id.item1 -> Toast.makeText(this,"Open Selected",Toast.LENGTH_SHORT).show() R.id.item2 -> Toast.makeText(this,"Search Selected",Toast.LENGTH_SHORT).show() R.id.item3 -> Toast.makeText(this,"Exit Selected",Toast.LENGTH_SHORT).show() } return super.onContextItemSelected(item) } }


OptionsMenu

java>new menu directory>new menu resource file named "menu_main.xml"

main.xml:

<android.support.constraint.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=".MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

menu_main.xml: