Found 417 Articles for Kotlin

How can I remove a button or make it invisible in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 09:19:57

2K+ Views

This example demonstrates how to remove a button or make it invisible in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport androidx.appcompat.app.AppCompatActivity import android.os.Bundle 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)       title = "KotlinApp"       ... Read More

How to detect Scroll Up & Scroll down in Android ListView using Kotlin?

Azhar
Updated on 18-Aug-2020 09:16:20

803 Views

This example demonstrates how to detect Scroll Up & Scroll down in Android ListView using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.* import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private var scrollView: ScrollView? = null    private lateinit var listView: ListView    private var numbers = arrayOf(       "1",       "2",     ... Read More

How to detect Android user agent type in general using kotlin?

Azhar
Updated on 18-Aug-2020 09:13:09

357 Views

This example demonstrates how to detect Android user agent type in general using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.media.AudioManager import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       ... Read More

How to add a line break in an Android TextView using Kotlin?

Azhar
Updated on 18-Aug-2020 09:08:47

701 Views

This example demonstrates how to add a line break in an Android TextView using Kotlin.space_on_android_devicesStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.graphics.Color import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.TextView class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val textView: TextView ... Read More

How to Check available space on Android devices using Kotlin?

Azhar
Updated on 18-Aug-2020 09:06:14

612 Views

This example demonstrates how to Check available space on Android devices using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.os.Environment import android.os.StatFs import android.text.format.Formatter import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.io.File class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"     ... Read More

How to pass drawables between activities in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 09:03:20

253 Views

This example demonstrates how to pass drawables between activities in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.content.Intent import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val button: Button = findViewById(R.id.button) ... Read More

How to send an email with a file attachment in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 09:00:11

1K+ Views

This example demonstrates how to send an email with a file attachment in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                 Step 3 − Add the following code to src/MainActivity.ktimport android.content.Intent import android.net.Uri import android.os.Bundle import android.view.View import android.widget.Button import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var ... Read More

How to change the Android Overflow menu icon programmatically using Kotlin?

Azhar
Updated on 18-Aug-2020 08:55:55

651 Views

This example demonstrates how to change the Android Overflow menu icon programmatically.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.ktimport android.graphics.Color import android.os.Bundle import android.view.Menu import android.view.MenuItem import android.widget.Toast import androidx.appcompat.widget.Toolbar import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var toolBar: Toolbar    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ... Read More

How to convert ISO 8601 String to Date/Time object in Android using Kotlin?

Azhar
Updated on 21-Jul-2020 13:57:04

2K+ Views

This example demonstrates how to convert an ISO 8601 String to Date/Time object in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.text.SimpleDateFormat import java.util.* class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ... Read More

How to change the color and font of Android ListView using Kotlin?

Azhar
Updated on 21-Jul-2020 13:53:35

633 Views

This example demonstrates how to change the color and font of Android ListView using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var operatingSystem: Array = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X")    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ... Read More

Advertisements