Android Articles

Page 19 of 125

How to create a swipe refresh layout in Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 4K+ Views

This example demonstrates how to create a swipe refresh layout 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Handler import android.widget.TextView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout class MainActivity : AppCompatActivity() {    lateinit var swipeRefreshLayout: SwipeRefreshLayout    lateinit var textView: TextView    var number: Int = 0    override fun onCreate(savedInstanceState: Bundle?) {   ...

Read More

How to create scrollable TextView on Android using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 2K+ Views

This example demonstrates how to create scrollable TextView 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.     Step 3 − Add the following code to src/MainActivity.ktimport androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.TextView class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val textView: TextView = findViewById(R.id.textView)   ...

Read More

How do I connect to a Wi-Fi network on Android programmatically using Kotlin?

Azhar
Azhar
Updated on 30-Nov-2020 2K+ Views

This example demonstrates how to connect to a Wi-Fi network on Android programmatically 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.net.wifi.WifiManager import android.os.Bundle import android.widget.Switch import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    private lateinit var wifiButton: Switch    lateinit var textView: TextView    lateinit var wifiManager: ...

Read More

Custom Progress Bar in Android using Kotlin.

Azhar
Azhar
Updated on 28-Nov-2020 2K+ Views

This example demonstrates how to create a custom Progress Bar 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 androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.ProgressBar class MainActivity : AppCompatActivity() {    lateinit var progressBar:ProgressBar    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       progressBar = ...

Read More

How to check internet connection availability and the network type on Android using Kotlin?

Azhar
Azhar
Updated on 28-Nov-2020 1K+ Views

This example demonstrates how to check internet connection availability and the network type 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.         Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.net.ConnectivityManager import android.os.Bundle import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ...

Read More

How to create EditText accepts Alphabets only in Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 327 Views

This example demonstrates how to create EditText accepts Alphabets only 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.kt        

Read More

How to add a TextView to a LinearLayout dynamically in Android using Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 2K+ Views

This example demonstrates how to add a TextView to a LinearLayout dynamically 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.os.Bundle import android.widget.LinearLayout import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinAp"       val linearLayout: LinearLayout = ...

Read More

Web Scraping in Android Application using Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 2K+ Views

This example demonstrates how to perform Web Scraping in 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 android.os.AsyncTask import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import org.jsoup.Jsoup import java.io.IOException @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    private lateinit var textView: TextView    lateinit var button: Button    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ...

Read More

How to create custom Alert Dialogs in an Android App using Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 2K+ Views

This example demonstrates how to create custom Alert Dialogs 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 src/MainActivity.ktimport android.app.Dialog import android.content.Context import android.os.Bundle import android.view.View import android.widget.Button import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val context: Context = this    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       ...

Read More

How to use XMLPullParser to parse XML in Android using Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 1K+ Views

This example demonstrates how to use XMLPullParser to parse XML 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 − Create a Layout resource file (row.xml) and add the following code −             Step 5 − Create a new asset folder, and inside the asset folder create a Android resource file (model.xml) and add the following code −   ...

Read More
Showing 181–190 of 1,250 articles
« Prev 1 17 18 19 20 21 125 Next »
Advertisements