Day 5 of Android Development
Hello everyone , After too many problems finally i created my first app on Android Studio .
Telegram id for apk: - https://t.me/+hZu9-FaImzAyYmU1
This is the basic app in which there is two button one is download and second one is upload the function of botton is to show pop up it is clicked .
Here is code
kotlin code
main_activity.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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btndownload"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="20dp"
android:text="Download" />
<Button
android:id="@+id/btnupload"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="20dp"
android:text="Upload" />
</LinearLayout>
MainActivity.kt
package com.example.firstapp
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
val buttonDownload = findViewById<Button>(R.id.btndownload)
val buttonUpload = findViewById<Button>(R.id.btnupload)
buttonDownload.setOnClickListener {
Toast.makeText(applicationContext, "Downloading...", Toast.LENGTH_SHORT).show()
}
buttonUpload.setOnClickListener {
Toast.makeText(applicationContext, "Uploading...", Toast.LENGTH_SHORT).show()
}
}
}
Comments
Post a Comment