Kotlin Articles

Page 20 of 21

How to use the TextWatcher class in kotlin?

Azhar
Azhar
Updated on 21-Apr-2020 5K+ Views

This example demonstrates how to use the TextWatcher class 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.                 Step 3 − Add the following code to MainActivity.ktimport android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.widget.EditText import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var input: EditText    lateinit var output: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ...

Read More

How to create Text to Speech in an Android App using Kotlin?

Azhar
Azhar
Updated on 21-Apr-2020 1K+ Views

This example demonstrates how to create Text to Speech in an 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.                             Step 3 − Add the following code to MainActivity.ktimport android.app.Activity import android.content.Intent import android.os.Bundle import android.speech.RecognizerIntent import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* import kotlin.collections.ArrayList class MainActivity : AppCompatActivity() {    private val REQUESTCODE = ...

Read More

How to use Date Time Picker Dialog in Kotlin Android?

Azhar
Azhar
Updated on 21-Apr-2020 4K+ Views

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

How to use CheckBox in Android Kotlin?

Azhar
Azhar
Updated on 21-Apr-2020 4K+ Views

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

Shared Preferences - Save, edit, retrieve, delete in Kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 737 Views

This example demonstrates how Save, edit, retrieve, delete shared preference data 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.                                     Step 3 − Add the following code to src/MainActivity.ktimport 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 @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") class MainActivity : AppCompatActivity() {    var editTextName: EditText? = ...

Read More

How can I use marquee text in Kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 1K+ Views

This example demonstrates how to use marquee text in an Android Kotlin App.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.TextView class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val text: String = "Simple application that shows how ...

Read More

Send data from one Fragment to another using Kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 5K+ Views

This example demonstrates how to send data from one Fragment to another 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 two FragmentActivity and add the codes which are given below.fragmentOne.xml −         FirstFragment.kt −import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import kotlinx.android.synthetic.main.fragment_one.view.* class FirstFragment : Fragment() {    private lateinit var communicator: Communicator    override fun onCreateView(       inflater: LayoutInflater, ...

Read More

How to use a simple SQLite database in Kotlin android?

Azhar
Azhar
Updated on 20-Apr-2020 5K+ Views

This example demonstrates how to use a simple SQLite database in Kotlin 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.                                    

Read More

How to create a notification alert using Kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 2K+ Views

This example demonstrates how to create a notification alert 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.ktpackage app.com.kotlinapp import android.app.* import android.content.Context import android.content.Intent import android.graphics.BitmapFactory import android.graphics.Color import android.os.Build import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var notificationChannel: NotificationChannel    lateinit var notificationManager: NotificationManager    lateinit var builder: Notification.Builder    private val channelId = "12345" ...

Read More

How to create a multilevel listView using Kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 424 Views

This example demonstrates how to create a multilevel listView using Kotlin 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.ktpackage app.com.kotlinapp import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() {    private val header: MutableList = ArrayList()    private val body: MutableList = ArrayList()    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       val myFavCricketPlayers: ...

Read More
Showing 191–200 of 202 articles
Advertisements