Found 1966 Articles for Apps/Applications

How to call a method after a delay in Android Kotlin?

Azhar
Updated on 23-May-2020 13:13:30

726 Views

This example demonstrates how to call a method after a delay 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.os.Bundle import android.os.Handler import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    private val string = "Delay by 5 seconds"    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

How can I save a HashMap to Sharedpreferences in Android Kotlin?

Azhar
Updated on 23-May-2020 13:08:29

748 Views

This example demonstrates how to save a HashMap to Sharedpreferences 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.Context import android.content.SharedPreferences 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 import org.json.JSONObject import java.util.* import kotlin.collections.HashMap class MainActivity : AppCompatActivity() {    private val mapKey = "map"    lateinit ... Read More

How to get a working vertical SeekBar in Android using Kotlin?

Azhar
Updated on 23-May-2020 12:49:51

372 Views

This example demonstrates how to listen for volume buttons in Android background service 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.widget.SeekBar import android.widget.SeekBar.OnSeekBarChangeListener import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var seekBar: SeekBar    lateinit var textView: TextView    var min = 0    var max: Int = 100    var current: Int ... Read More

How to use BroadcastReceiver in Kotlin?

Azhar
Updated on 23-May-2020 12:45:54

4K+ Views

This example demonstrates how to use BroadcastReceiver 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.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter import android.net.wifi.WifiManager import android.os.Bundle import android.widget.Switch import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var wifiSwitch: Switch    lateinit var wifiManager: WifiManager    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

How to pass an arrayList to another activity using intents in Android Kotlin?

Azhar
Updated on 23-May-2020 12:39:06

4K+ Views

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

How to develop an Speech recognizer in Android without Google API in Kotlin?

Azhar
Updated on 23-May-2020 12:34:05

2K+ Views

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

How to use ViewFlipper Android using Kotlin?

Azhar
Updated on 05-Nov-2020 14:53:06

328 Views

This example demonstrates how to use ViewFlipper 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.view.Gravity import android.view.View import android.widget.TextView import android.widget.ViewFlipper class MainActivity : AppCompatActivity() {    lateinit var viewFlipper: ViewFlipper    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main) ... Read More

How to set a timer in Android using Kotlin?

Azhar
Updated on 23-May-2020 12:12:26

5K+ Views

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

How to get the selected index of a RadioGroup in Android using Kotlin?

Azhar
Updated on 23-May-2020 12:07:21

2K+ Views

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

How to create a Expandable listView using Kotlin?

Azhar
Updated on 23-May-2020 12:00:28

3K+ Views

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

Advertisements