Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Azhar
Page 4 of 46
How to create EditText accepts Alphabets only in Kotlin?
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 MoreHow to add a TextView to a LinearLayout dynamically in Android using Kotlin?
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 MoreWeb Scraping in Android Application using Kotlin?
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 MoreHow to create custom Alert Dialogs in an Android App using Kotlin?
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 MoreHow to use XMLPullParser to parse XML in Android using Kotlin?
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 MoreHow to listen for a WebView finishing loading a URL in Android using Kotlin?
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 MoreHow to convert pixels to dp in an Android App using Kotlin?
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 MoreHow to create a Custom Ratingbar in Android using Kotlin?
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 MoreHow do I restart an Android Activity using Kotlin?
This example demonstrates how to restart an Android Activity 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.TextView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() { lateinit var textView: TextView lateinit var button: Button var random: Random = Random() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ...
Read MoreAndroid imageView Zoom-in and Zoom-Out using Kotlin?
This example demonstrates how to implement Android imageView zoom-in and Zoom out 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.MotionEvent import android.view.ScaleGestureDetector import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import kotlin.math.max import kotlin.math.min class MainActivity : AppCompatActivity() { private lateinit var scaleGestureDetector: ScaleGestureDetector private var scaleFactor = 1.0f private lateinit var imageView: ImageView override fun ...
Read More