This example demonstrates how to pass an arrayList to another activity using intents 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.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.content.Intent import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var button: Button var numbers: ArrayList = ArrayList() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ... Read More
This example demonstrates how to develop an Speech recognizer in Android without Google API in 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.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.Manifest import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle import android.speech.RecognitionListener import android.speech.RecognizerIntent import android.speech.SpeechRecognizer import android.util.Log import android.view.View import android.widget.ProgressBar import android.widget.TextView import android.widget.Toast import android.widget.ToggleButton import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat class MainActivity : AppCompatActivity(), ... Read More
This example demonstrates how to set a timer 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.Example Step 3 − Add the following code to src/MainActivity.ktexampleimport android.os.Bundle import android.os.CountDownTimer import android.view.View import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { var counter = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" ... Read More
This example demonstrates how to get the selected index of a RadioGroup in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill allrequired details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.Bundle import android.widget.Button import android.widget.RadioButton import android.widget.RadioGroup import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { private lateinit var textView: TextView private lateinit var button: Button ... Read More
This example demonstrates how to create a Expandable 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 project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Create a new kotlin class CustomExpandableListAdapter.kt and add the following code −Exampleimport android.content.Context import android.graphics.Typeface import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.BaseExpandableListAdapter import android.widget.TextView import java.util.HashMap class CustomExpandableListAdapter internal constructor( private val context: Context, private val titleList: List, private val dataList: HashMap ) : BaseExpandableListAdapter() { ... Read More
This example demonstrates how to detect shake events in 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.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.content.Context import android.hardware.Sensor import android.hardware.SensorEvent import android.hardware.SensorEventListener import android.hardware.SensorManager import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* import kotlin.math.sqrt class MainActivity : AppCompatActivity() { private var sensorManager: SensorManager? = null private var acceleration = 0f private var currentAcceleration = 0f ... Read More
This example demonstrates how to implement bar code scanning in 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.Example Step 3 − Add the following the dependency to build.gradle (Module:app)implementation 'com.google.zxing:core:3.3.3' implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'Step 4 − Add the following code to src/MainActivity.ktExampleimport android.content.Intent import android.os.Bundle import android.util.Log import android.widget.Button import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.google.zxing.integration.android.IntentIntegrator class MainActivity : AppCompatActivity() { lateinit var btnBarcode: Button lateinit var textView: ... Read More
To set the background in JavaScript, use the background property. It allows you to set the background color, image, position, etc.ExampleYou can try to run the following code to learn how to set all the background properties in a single declaration with JavaScript.Live Demo Click to Set background function display() { document.body.style.background = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg') repeat right top"; }
This example demonstrates how to automatically start and stop an Async task in 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.Example Step 3 − Add the following code to src/MainActivity.ktExampleimport android.os.AsyncTask import android.os.Bundle import android.view.View import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* import java.lang.ref.WeakReference class MainActivity : AppCompatActivity() { var variable = 10 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) ... Read More
To get the pathname part of the href attribute of an area in JavaScript, use the pathname property.ExampleYou can try to run the following code to display the pathname part. var x = document.getElementById("myarea").pathname; document.write("Pathname: "+x);
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP