Found 1966 Articles for Apps/Applications

How to pick an image from an image gallery on Android using Kotlin?

Azhar
Updated on 30-Nov-2020 04:15:19

9K+ Views

This example demonstrates how to pick an image from an image gallery 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.content.Intent import android.net.Uri import android.os.Bundle import android.provider.MediaStore import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    lateinit var button: Button    private val pickImage = 100    private var ... Read More

How to create scrollable TextView on Android using Kotlin?

Azhar
Updated on 30-Nov-2020 03:53:23

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 to create multiple styles inside a TextView on Android using Kotlin?

Azhar
Updated on 30-Nov-2020 03:48:01

662 Views

This example demonstrates how to create multiple styles inside a 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 android.os.Bundle import android.text.Html import android.widget.TextView import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    private lateinit var textView2: TextView    lateinit var textView3: TextView    override fun onCreate(savedInstanceState: Bundle?) { ... Read More

How to parse JSON Objects on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 12:53:28

3K+ Views

This example demonstrates how to parse JSON Objects 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 − Create a new asset folder and create a user_list.json file and the code mentioned below.{    "users":[       {          "name":"Niyaz",          "email":"testemail1@gmail.com",          "contact":{             "mobile":"+91 0000000000"          } ... Read More

How to handle right-to-left and left-to-right swipe gestures on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 12:45:04

942 Views

This example demonstrates how to handle right-to-left and left-to-right swipe gestures 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.view.GestureDetector import android.view.MotionEvent import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import kotlin.math.abs class MainActivity : AppCompatActivity(), GestureDetector.OnGestureListener {    lateinit var gestureDetector: GestureDetector    private val swipeThreshold = 100    private val swipeVelocityThreshold = 100    override fun onCreate(savedInstanceState: ... Read More

How to check if an Android application is running in the background using Kotlin?

Azhar
Updated on 28-Nov-2020 12:39:57

1K+ Views

This example demonstrates how to check if an Android application is running in the background 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.ActivityManager import android.app.ActivityManager.RunningAppProcessInfo import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var appRunningBackground: Boolean = false    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ... Read More

How to start a new activity by clicking a button on Android using Kotlin?

Azhar
Updated on 28-Nov-2020 12:30:51

2K+ Views

This example demonstrates how to start new activity on click button on 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       val button: Button = findViewById(R.id.button)       button.setOnClickListener ... Read More

Android bundle to pass data between activities using Kotlin.

Azhar
Updated on 28-Nov-2020 12:26:45

3K+ Views

This example demonstrates how to pass data between activities 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.text.TextUtils import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.io.Serializable class MainActivity : AppCompatActivity() {    lateinit var etName: EditText    lateinit var etPhone: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

Custom Progress Bar in Android using Kotlin.

Azhar
Updated on 28-Nov-2020 12:14:10

1K+ 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

How to make an Android Spinner with initial default text using Kotlin?

Azhar
Updated on 28-Nov-2020 12:11:03

818 Views

This example demonstrates how to make an Android Spinner with initial default text 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.view.View import android.widget.AdapterView import android.widget.AdapterView.OnItemSelectedListener import android.widget.ArrayAdapter import android.widget.Spinner import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var spinner: Spinner    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ... Read More

Advertisements