Found 417 Articles for Kotlin

How to define a MIN and MAX value for EditText in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 07:25:16

671 Views

This example demonstrates how to define a MIN and MAX value for EditText in Android using KotlinStep 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.text.InputFilter import android.text.Spanned import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

How can I validate EditText input in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 07:14:29

1K+ Views

This example demonstrates how to validate EditText input 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.os.Bundle import android.text.InputFilter import android.text.Spanned import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* import java.util.regex.Matcher import java.util.regex.Pattern class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

How to check if Location Services are enabled in Android App using Kotlin?

Azhar
Updated on 30-Nov-2020 07:08:00

1K+ Views

This example demonstrates how to check if Location Services are enabled in Android App 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.location.LocationManager import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var gpsStatus: Boolean = false    private lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {   ... Read More

How to create circular ProgressBar in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 07:02:52

2K+ Views

This example demonstrates how to create a circular ProgressBar 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 − Create a drawable resource file (circularprogressbar.xml) and add the following code    android:layout_width="wrap_content"    android:layout_height="wrap_content">                                                   ... Read More

How to detect click on HTML button through javascript in Android WebView using Kotlin?

Azhar
Updated on 30-Nov-2020 06:56:01

1K+ Views

This example demonstrates how to detect click on HTML buttons through javascript in Android WebView using Kotlin.This example demonstrates how to detect click on HTML buttons through javascript in Android WebView 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 − Create an asset folder and create a file.htm and add the following code − First name: Last name:    function getValues() { ... Read More

How to make a phone call using intent in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 06:31:34

3K+ Views

This example demonstrates how to make a phone call using intent in Android using KotlinStep 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 androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }    fun ... Read More

How to turn Android device screen on and off programmatically using Kotlin?

Azhar
Updated on 30-Nov-2020 05:28:49

1K+ Views

This example demonstrates how to turn an Android device screen on and off programmatically 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.app.admin.DevicePolicyManager import android.content.ComponentName import android.content.Context import android.content.Intent import android.os.Bundle import android.view.View import android.widget.Button import android.widget.Toast import androidx.annotation.Nullable import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val enableResult = 1   ... Read More

How to resize Image in Android App using Kotlin?

Azhar
Updated on 30-Nov-2020 05:23:02

3K+ Views

This example demonstrates how to resize Image in an Android App 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.app.Activity import android.content.Intent import android.graphics.Bitmap import android.net.Uri import android.os.Bundle import android.provider.MediaStore import android.view.View import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import java.io.IOException class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    private val pickImage = ... Read More

How to create pagination text in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 12:35:49

251 Views

This example demonstrates how to create pagination text 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.graphics.Color import android.graphics.Typeface import android.os.Bundle import android.text.Html import android.text.Spannable import android.text.SpannableString import android.text.TextUtils import android.text.style.ForegroundColorSpan import android.text.style.RelativeSizeSpan import android.text.style.StyleSpan import android.view.ViewTreeObserver import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var ... Read More

How to implement a long click listener on an Android listview using Kotlin?

Azhar
Updated on 18-Aug-2020 12:30:38

793 Views

This example demonstrates how to implement a long click listener on an 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 projectStep 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.AdapterView.OnItemLongClickListener import android.widget.ArrayAdapter import android.widget.ListView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var mobileArray = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X")    override fun onCreate(savedInstanceState: Bundle?) {       ... Read More

Advertisements