Mobile Development Articles

Page 29 of 156

How to write a custom adapter for my list view on Android using Kotlin?

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

This example demonstrates how to write a custom adapter for my list view 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.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.ListView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var listView: ListView    var arrayList: ArrayList = ArrayList()    var adapter: MyAdapter? = ...

Read More

How to show current progress while downloading a file on Android App using Kotlin?

Azhar
Azhar
Updated on 28-Nov-2020 637 Views

This example demonstrates how to show current progress while downloading a file on 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.os.Bundle import android.view.View import android.webkit.WebView import android.widget.ProgressBar import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var webView: WebView    lateinit var progressBar: ProgressBar    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ...

Read More

How to create EditText accepts Alphabets only in Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 311 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

How to listen for a WebView finishing loading a URL in Android using Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 965 Views

This example demonstrates how to listen for a WebView finishing loading a URL 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.webkit.WebChromeClient import android.webkit.WebView import android.webkit.WebViewClient import android.widget.Button import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var webView: WebView    lateinit var textView: TextView    private lateinit var ...

Read More

How to convert pixels to dp in an Android App using Kotlin?

Azhar
Azhar
Updated on 05-Nov-2020 842 Views

This example demonstrates how to convert pixels to dp 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.content.Context import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import kotlin.math.roundToInt class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ...

Read More

How to create a Custom Ratingbar in Android using Kotlin?

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

This example demonstrates how to create a Custom Ratingbar 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.Button import android.widget.RatingBar import android.widget.RatingBar.OnRatingBarChangeListener import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var ratingBar: RatingBar    lateinit var button: Button    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) { ...

Read More
Showing 281–290 of 1,551 articles
« Prev 1 27 28 29 30 31 156 Next »
Advertisements