Found 2041 Articles for Mobile Development

How to use Calendar Widget using the CalendarView class in Android App using Kotlin?

Azhar
Updated on 05-Nov-2020 14:54:44

894 Views

This example demonstrates how to use Calendar Widget using the CalendarView class in 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.widget.CalendarView import android.widget.CalendarView.OnDateChangeListener import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var calendarView: CalendarView    lateinit var dateView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

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

Azhar
Updated on 05-Nov-2020 14:54:00

1K+ 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 SearchView in Android Kotlin?

Azhar
Updated on 05-Nov-2020 14:49:17

3K+ Views

This example demonstrates how to use SearchView 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.ArrayAdapter import android.widget.ListView import android.widget.SearchView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var searchView: SearchView    lateinit var listView: ListView    lateinit var list: ArrayList    lateinit var adapter: ArrayAdapter    override fun onCreate(savedInstanceState: Bundle?) {   ... Read More

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

Azhar
Updated on 05-Nov-2020 14:48:07

877 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 use JSONObject to parse JSON in Android using Kotlin?

Azhar
Updated on 05-Nov-2020 14:47:22

2K+ Views

This example demonstrates how to use JSONObject to parse JSON 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.TextView import androidx.appcompat.app.AppCompatActivity import org.json.JSONException import org.json.JSONObject class MainActivity : AppCompatActivity() {    private val jsonString = "{\"Employee\":{\"Name\":\"Niyaz\", \"Salary\":56000}}"    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       ... Read More

How to use Location API in Android to track your current location using Kotlin?

Azhar
Updated on 05-Nov-2020 14:46:38

347 Views

This example demonstrates how to use Location API in Android to track your current location 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_maps.xml. Step 3 − Add the following code to src/MapsActivity.ktimport android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.OnMapReadyCallback import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.MarkerOptions class MapsActivity : AppCompatActivity(), OnMapReadyCallback {    private lateinit var mMap: GoogleMap    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_maps) ... Read More

How to get the device's IMEI/ESN programmatically in android using Kotlin?

Azhar
Updated on 05-Nov-2020 14:45:54

2K+ Views

This example demonstrates how to get the device's IMEI/ESN programmatically 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.Manifest import android.content.Context import android.content.pm.PackageManager import android.os.Bundle import android.telephony.TelephonyManager import android.widget.Button import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat class MainActivity : AppCompatActivity() {    lateinit var button: Button    lateinit var textView: TextView    private lateinit ... Read More

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

Azhar
Updated on 05-Nov-2020 14:45:09

647 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 do I use InputFilter to limit characters in an EditText in Android Kotlin?

Azhar
Updated on 05-Nov-2020 14:42:41

1K+ Views

This example demonstrates how to use InputFilter to limit characters in an EditText 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.text.InputFilter import android.text.InputFilter.LengthFilter import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title ... Read More

How to open a website in Android's web browser from my application using Kotlin?

Azhar
Updated on 30-Nov-2020 04:12:09

716 Views

This example demonstrates how to open a website in Android's web browser from my 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.content.Intent import android.net.Uri import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp" ... Read More

Advertisements