Kotlin Articles

Page 12 of 21

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

Azhar
Azhar
Updated on 30-Nov-2020 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
Azhar
Updated on 30-Nov-2020 4K+ 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 change a TextView's style at runtime in Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 3K+ Views

This example demonstrates how to change a TextView's style at runtime 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 in res/values/styles.xml           bold|italic       #FFFFFF               normal       #C0C0C0     Step 4 − Add the following code in res/values/colors.xml    @android:color/holo_green_light    @android:color/holo_red_dark Step ...

Read More

How to send a notification from a service in Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 2K+ Views

This example demonstrates how to send a notification from a service 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.view.View import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ...

Read More

How to disable GridView scrolling in Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 392 Views

This example demonstrates how to disable GridView scrolling 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.Context import android.os.Bundle import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.* import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var gridView: GridView       var imageIDs = arrayOf(          R.drawable.ronaldo,          R.drawable.andre, ...

Read More

How to use Android Picasso library to download images using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 665 Views

This example demonstrates how to use the Android Picasso library to download images 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.Add the following dependency to the build gradle (Module: app)implementation 'com.squareup.picasso:picasso:2.4.0'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.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import com.squareup.picasso.Picasso class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    lateinit var btnDownload: Button    override fun onCreate(savedInstanceState: ...

Read More

How to create a swipe refresh layout in Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 4K+ Views

This example demonstrates how to create a swipe refresh layout 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.os.Handler import android.widget.TextView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout class MainActivity : AppCompatActivity() {    lateinit var swipeRefreshLayout: SwipeRefreshLayout    lateinit var textView: TextView    var number: Int = 0    override fun onCreate(savedInstanceState: Bundle?) {   ...

Read More

How to create scrollable TextView on Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 2K+ Views

This example demonstrates how to create scrollable TextView on 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.text.method.ScrollingMovementMethod 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 = findViewById(R.id.textView)   ...

Read More

How do I connect to a Wi-Fi network on Android programmatically using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 2K+ Views

This example demonstrates how to connect to a Wi-Fi network on Android 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.content.Context import android.net.wifi.WifiManager import android.os.Bundle import android.widget.Switch import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    private lateinit var wifiButton: Switch    lateinit var textView: TextView    lateinit var wifiManager: ...

Read More

Custom Progress Bar in Android using Kotlin.

Azhar
Azhar
Updated on 28-Nov-2020 2K+ Views

This example demonstrates how to create a custom Progress Bar 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.widget.ProgressBar class MainActivity : AppCompatActivity() {    lateinit var progressBar:ProgressBar    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       progressBar = ...

Read More
Showing 111–120 of 202 articles
« Prev 1 10 11 12 13 14 21 Next »
Advertisements