Mobile Development Articles

Page 31 of 156

How to create pagination text in Android using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 414 Views

This example demonstrates how to create pagination text 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.graphics.Color import android.graphics.Typeface import android.os.Bundle import android.text.Html import android.text.Spannable import android.text.SpannableString import android.text.TextUtils import android.text.style.ForegroundColorSpan import android.text.style.RelativeSizeSpan import android.text.style.StyleSpan import android.view.ViewTreeObserver import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var ...

Read More

How to bring an activity to the foreground i.e. top of stack using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 648 Views

This example demonstrates how to bring an activity to the foreground i.e. top of stack 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 projectStep 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.ktimport android.content.Intent import android.os.Bundle import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val i = Intent(this, NewActivity::class.java) ...

Read More

How to use search functionality in custom listview in Android using kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 810 Views

This example demonstrates how to use search functionality in custom listview in Android using kotlinStep 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.text.Editable import android.text.TextWatcher import android.widget.ArrayAdapter import android.widget.EditText import android.widget.ListView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var listView: ListView    var months: ArrayList = ArrayList()    var arrayAdapter: ArrayAdapter? = null    lateinit var ...

Read More

How can we get the current language selected in the Android device using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 1K+ Views

This example demonstrates how to get the current language selected in the Android device 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 java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val textView: ...

Read More

How to use the recyclerview with a database in Android using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 2K+ Views

This example demonstrates how to use the recyclerview with a database 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.text.TextUtils import android.view.LayoutInflater import android.view.View import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView class MainActivity : AppCompatActivity() {    private lateinit var dataBase: SqliteDatabase    override fun onCreate(savedInstanceState: Bundle?) { ...

Read More

How to run a method every 10 seconds in Android using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 4K+ Views

This example demonstrates how to run a method every 10 seconds 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.os.Handler import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    var handler: Handler = Handler()    var runnable: Runnable? = null    var delay = 10000    override fun onCreate(savedInstanceState: Bundle?) {       ...

Read More

How to handle the click event in Listview in Android using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 3K+ Views

This example demonstrates how to handle the click event in Listview 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.ArrayAdapter import android.widget.ListView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlin.collections.ArrayList class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"     ...

Read More

How to play YouTube videos in my Android application using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 1K+ Views

This example demonstrates how to play YouTube videos in my Android application 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 androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import java.util.* class MainActivity : AppCompatActivity() {    private lateinit var recyclerView:RecyclerView    private var youtubeVideos = Vector()    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ...

Read More

How to detect swipe direction between left/right and up/down in Android using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 903 Views

This example demonstrates how to detect swipe direction between left/right and up/down 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.content.Context import android.os.Bundle import android.view.GestureDetector import android.view.MotionEvent import android.view.View import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import kotlin.math.abs class MainActivity : AppCompatActivity() {    var onSwipeTouchListener: OnSwipeTouchListener? = null    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)   ...

Read More

How to display progress dialog before starting an activity in Android using Kotlin?

Azhar
Azhar
Updated on 18-Aug-2020 428 Views

This example demonstrates how to display progress dialog before starting an activity 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 android.os.AsyncTask import android.os.Bundle import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    private lateinit var progressDialog: ProgressDialog    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title ...

Read More
Showing 301–310 of 1,551 articles
« Prev 1 29 30 31 32 33 156 Next »
Advertisements