Skip to content

A simple yet efficient click counter app built with Kotlin and Android Studio. This app increments a counter each time a button is pressed, providing real-time updates with a clean and responsive UI. Perfect for tracking counts, learning Android development, and showcasing Kotlin skills. πŸš€

License

Notifications You must be signed in to change notification settings

naomi-afrin/clickCounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± Click Counter App

A simple Android app built with Kotlin that increments a counter each time a button is clicked. The app uses a TextView to display the counter value and updates it dynamically on button press.

πŸš€ Features

  • Click the button to increase the counter.
  • Displays the updated counter value instantly.
  • Simple and clean UI using ConstraintLayout.

πŸ“Έ Demo

Demo GIF

πŸ› οΈ Technologies Used

  • Kotlin
  • Android Studio
  • ConstraintLayout

πŸ“‚ Project Structure

ClickCounterApp/
│── app/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”‚   β”œβ”€β”€ java/com/example/clickcounter/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MainActivity.kt
β”‚   β”‚   β”‚   β”œβ”€β”€ res/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main_activity.xml
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ drawable/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ bg.xml
│── build.gradle
│── AndroidManifest.xml

πŸ“œ Code Overview

MainActivity.kt

class MainActivity : ComponentActivity() {
    var counter = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main_activity)

        val btn: Button = findViewById(R.id.btn)
        val result_txt: TextView = findViewById(R.id.textView)

        btn.setOnClickListener {
            result_txt.setText("" + increaseCounter())
        }
    }
    fun increaseCounter(): Int{
        counter++
        return counter
    }
}

main_activity.xml

<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:background="@drawable/bg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:textSize="48sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click me"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout>

πŸ”§ How to Run the Project

  1. Clone this repository:
    git clone https://github.com/naomi-afrin/ClickCounterApp.git
  2. Open Android Studio and open the project.
  3. Connect a physical or virtual device.
  4. Click Run β–Ά to build and run the app.

πŸ“Œ Future Updates

  • Add animations for button clicks.
  • Implement dark mode support.
  • Store the counter value using SharedPreferences.

✨ Contributing

Contributions are welcome! Feel free to fork this repo, make improvements, and submit a pull request.

πŸ“„ License

This project is licensed under the MIT License.


Made with ❀️ by Naomi Afrin Jalil

About

A simple yet efficient click counter app built with Kotlin and Android Studio. This app increments a counter each time a button is pressed, providing real-time updates with a clean and responsive UI. Perfect for tracking counts, learning Android development, and showcasing Kotlin skills. πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages