- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 417 Articles for Kotlin
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
1K+ Views
This example demonstrates how to use InputFilter to limit characters in an EditText in Android 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.InputFilter.LengthFilter import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var editText: EditText override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
715 Views
This example demonstrates how to open a website in Android's web browser from my application 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.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" ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
631 Views
This example demonstrates how to convert pixels to dp 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.content.Context import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlin.math.roundToInt class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
4K+ Views
This example demonstrates how to show current location on a Google Map 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 given dependency in the build.gradle (Module: app)implementation 'com.google.android.gms:play-services-maps:17.0.0' implementation 'com.google.android.gms:play-services-location:17.0.0' implementation 'com.google.android.gms:play-services-maps:17.0.0'Step 4 − Add the following code to src/MainActivity.ktimport android.Manifest import android.content.pm.PackageManager import android.location.Location import android.os.Bundle import android.widget.Toast import androidx.core.app.ActivityCompat import androidx.fragment.app.FragmentActivity import com.google.android.gms.location.FusedLocationProviderClient import com.google.android.gms.location.LocationServices import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.OnMapReadyCallback import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.model.LatLng ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
3K+ Views
This example demonstrates how to get the IP address of the Android device 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.text.format.Formatter import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
588 Views
This example demonstrates how to retrieve Android API version 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.os.Build import android.os.Bundle import android.widget.Button import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var button: Button lateinit var textView: TextView var androidVersion = 0 override fun onCreate(savedInstanceState: Bundle?) { ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
1K+ Views
This example demonstrates how to draw a line 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.Bitmap import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint import android.os.Bundle import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var button: Button lateinit var imageView: ImageView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
840 Views
This example demonstrates how to rotate an image in imageview by an angle 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 android.os.Bundle import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var imageView: ImageView lateinit var btnRotate: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
707 Views
This example demonstrates how to set the color of TextView span 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.os.Bundle import android.text.SpannableString import android.text.Spanned import android.text.style.ForegroundColorSpan import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var textView:TextView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) ... Read More
![Azhar](https://www.tutorialspoint.com/assets/profiles/124637/profile/60_166181-1565938637.jpg)
3K+ Views
This example demonstrates how to parse HTML 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 given dependency in the build.gradle (Module: app)implementation 'org.jsoup:jsoup:1.11.2'Step 4 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.select.Elements import java.io.IOException class MainActivity : AppCompatActivity() { lateinit var button: Button lateinit var textView: TextView ... Read More