This example demonstrates how to show a progress dialog 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.app.ProgressDialog import androidx.appcompat.app.AppCompatActivity import android.os.Bundle @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val progressDialog = ProgressDialog(this@MainActivity) ... Read More
This example demonstrates how to iterate a JSON Array 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.widget.TextView import androidx.appcompat.app.AppCompatActivity import org.json.JSONObject @Suppress("NAME_SHADOWING") class MainActivity : AppCompatActivity() { private lateinit var textView: TextView var strJson = ("{ \"Employee\" :[{\"ID\":\"01\", \"Name\":\"Sam\", \"Salary\":\"50000\"}, " + "{\"ID\":\"02\", \"Name\":\"Shankar\", \"Salary\":\"60000\"}] }") override fun onCreate(savedInstanceState: Bundle?) { ... Read More
This example demonstrates how to use Date Time Picker Dialog 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.app.DatePickerDialog import android.app.TimePickerDialog import android.os.Bundle import android.text.format.DateFormat import android.widget.Button import android.widget.DatePicker import android.widget.TextView import android.widget.TimePicker import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity(), DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener { lateinit var textView: TextView lateinit var button: Button var ... Read More
This example demonstrates how to use Snackbar 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.graphics.Color import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button import android.widget.TextView import com.google.android.material.snackbar.Snackbar class MainActivity : AppCompatActivity() { lateinit var button: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" ... Read More
This example demonstrates how to use CheckBox 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.widget.Button import android.widget.CheckBox import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.lang.StringBuilder class MainActivity : AppCompatActivity() { lateinit var pizza: CheckBox lateinit var coffee: CheckBox lateinit var burger: CheckBox lateinit var button: Button ... Read More
This example demonstrates how to use Radio Button 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.widget.Button import android.widget.RadioButton import android.widget.RadioGroup import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { var radioGroup: RadioGroup? = null lateinit var radioButton: RadioButton private lateinit var button: Button ... Read More
This example demonstrates how to dynamically update a ListView on 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.ArrayAdapter import android.widget.Button import android.widget.EditText import android.widget.ListView class MainActivity : AppCompatActivity() { lateinit var editText: EditText lateinit var button: Button lateinit var listView: ListView var list: ArrayList = ArrayList() lateinit ... Read More
This example demonstrates how to check if a Bluetooth device is connected with an Android device..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.bluetooth.BluetoothDevice import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = ... Read More
This example demonstrates how to display a list view in an Android Alert Dialog.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.ArrayAdapter import android.widget.ListView import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { var country = arrayOf( "India", "Brazil", "Argentina", "Portugal", "France", "England", "Italy" ) ... Read More
Subscriber interface subscribes to publishers to receive items through onNext() method, error message through the onError() method, or a signal that no more items to be expected through the onComplete() method. Before any of those things happen, the publisher calls onSubscription() method.public interface Subscriber { public void onSubscribe(Subscription s); public void onNext(T t); public void onError(Throwable t); public void onComplete(); }Rules for Subscriber interface:A Subscriber must call through Subscription.request(long n) method to receive onNext() signals.Subscriber.onComplete() and Subscriber.onError(Throwable t) methods must not call any methods on Subscription or Publisher.Subscriber.onComplete() and Subscriber.onError(Throwable t) methods must consider the Subscription canceled after received ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP