Awaiting on Dynamic Imports in JavaScript

AmitDiwan
Updated on 22-Jul-2020 07:42:30

172 Views

Note − You will need a localhost server to run this example −Following is the code for dynamic imports in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Awaiting on dynamic imports in JavaScript CLICK HERE Click on the above button to dynamically import modules    document.querySelector(".Btn").addEventListener("click", loadModule);    let resEle = document.querySelector(".result");    async function loadModule() {   ... Read More

Nesting Template Strings in JavaScript

AmitDiwan
Updated on 22-Jul-2020 07:40:39

586 Views

Following is the code for nesting template strings in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;       color: blueviolet;    } Nesting template strings in JavaScript CLICK HERE Click on the above button to display the fullName using nested template string    let resEle = document.querySelector(".result");    let BtnEle = document.querySelector(".Btn");    function fullName(fName, lName) {       return fName + " " + lName;    }    let firstName = "Rohan";    let lastName = "Sharma";    BtnEle.addEventListener("click", () => {       resEle.innerHTML = `FirstName = ${firstName} and lastname = ${lastName} and       fullname = ${fullName(          `${firstName}`,          `${lastName}`       )}`;    }); OutputOn clicking the ‘CLICK HERE’ button −

Convert ISO 8601 String to DateTime Object in Android using Kotlin

Azhar
Updated on 21-Jul-2020 13:57:04

3K+ Views

This example demonstrates how to convert an ISO 8601 String to Date/Time object 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.ktimport android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.text.SimpleDateFormat import java.util.* class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ... Read More

Change Background Color of ListView Items on Android using Kotlin

Azhar
Updated on 21-Jul-2020 13:50:02

575 Views

This example demonstrates how to change the background color of ListView items on Android.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.ktimport android.os.Build import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView class MainActivity : AppCompatActivity() {    var operatingSystem: Array = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X")    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main) ... Read More

Find Currently Running Applications Programmatically in Android Using Kotlin

Azhar
Updated on 21-Jul-2020 13:45:58

843 Views

This example demonstrates how to find the currently running applications programmatically 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.ktimport android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val ... Read More

Remove Lines Between ListViews on Android using Kotlin

Azhar
Updated on 21-Jul-2020 13:42:16

192 Views

This example demonstrates how to remove lines between ListViews 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.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var listView: ListView    var mobilePhones = arrayOf("Samsung", "Iphone", "Nokia", "Alcatel", "Blackberry", "Oppo", "Sony")    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ... Read More

Copy Text Programmatically in Android App using Kotlin

Azhar
Updated on 21-Jul-2020 13:38:36

451 Views

This example demonstrates how to copy text programmatically (Ctrl+C) in my 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.Example Step 3 − Add the following code to src/MainActivity.ktimport android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.os.Bundle import android.view.View import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    lateinit var textView: TextView    lateinit var clipboardManager: ClipboardManager   ... Read More

Change Status Bar Color to Match App in Android Using Kotlin

Azhar
Updated on 21-Jul-2020 13:34:48

1K+ Views

This example demonstrates how to change status bar color to match app 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.ktimport android.os.Bundle import android.view.Window import android.view.WindowManager import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val window: Window = ... Read More

Set Layout Weight of TextView Programmatically in Android Using Kotlin

Azhar
Updated on 21-Jul-2020 13:30:47

1K+ Views

This example demonstrates how to set the layout weight of a TextView programmatically in Android.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.Button import android.widget.RelativeLayout import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }    fun expand(view: View) { ... Read More

Show Dialog in Full Screen in Android Using Kotlin

Azhar
Updated on 21-Jul-2020 13:26:23

2K+ Views

This example demonstrates how to set dialog to show with full screen 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.ktimport android.app.Dialog 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 clickHere(view: View) {   ... Read More

Advertisements