Found 2041 Articles for Mobile Development

How to change a TextView's style at runtime in Android using Kotlin?

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

2K+ Views

This example demonstrates how to change a TextView's style at runtime 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 in res/values/styles.xml           bold|italic       #FFFFFF               normal       #C0C0C0     Step 4 − Add the following code in res/values/colors.xml    @android:color/holo_green_light    @android:color/holo_red_dark Step ... Read More

How to send a notification from a service in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 05:13:41

2K+ Views

This example demonstrates how to send a notification from a service 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.Intent import android.os.Bundle import android.view.View import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() {    lateinit var editText: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ... Read More

How does one use glide to download an image into a bitmap using Kotlin?

Azhar
Updated on 30-Nov-2020 05:08:08

615 Views

This example demonstrates how to use glide to download an image into a bitmap 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.graphics.Bitmap import android.graphics.drawable.Drawable import android.os.Bundle import android.widget.ImageView import androidx.annotation.Nullable import androidx.appcompat.app.AppCompatActivity import com.bumptech.glide.Glide import com.bumptech.glide.request.target.CustomTarget import com.bumptech.glide.request.transition.Transition; class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

How to disable GridView scrolling in Android using Kotlin?

Azhar
Updated on 30-Nov-2020 04:49:17

258 Views

This example demonstrates how to disable GridView scrolling 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.MotionEvent import android.view.View import android.view.ViewGroup import android.widget.* import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var gridView: GridView       var imageIDs = arrayOf(          R.drawable.ronaldo,          R.drawable.andre, ... Read More

How to display progress while loading a url to webview in android?

Azhar
Updated on 30-Nov-2020 04:45:02

617 Views

This example demonstrates how to display progress while loading a url to webview in android.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)       setContentView(R.layout.activity_main) ... Read More

How to use Android Picasso library to download images using Kotlin?

Azhar
Updated on 30-Nov-2020 04:41:35

433 Views

This example demonstrates how to use the Android Picasso library to download images 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.Add the following dependency to the build gradle (Module: app)implementation 'com.squareup.picasso:picasso:2.4.0'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.ImageView import androidx.appcompat.app.AppCompatActivity import com.squareup.picasso.Picasso class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    lateinit var btnDownload: Button    override fun onCreate(savedInstanceState: ... Read More

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

Azhar
Updated on 30-Nov-2020 04:33:51

3K+ 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 close all Android activities at once using Kotlin?

Azhar
Updated on 30-Nov-2020 04:28:50

790 Views

This example demonstrates how to close all Android activities at once 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.ktpackage com.example.q28 import android.content.Intent import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var button: Button    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = ... Read More

How to get the Android Emulator's IP address using Kotlin?

Azhar
Updated on 30-Nov-2020 04:20:53

261 Views

This example demonstrates how to get the Android Emulator's IP address 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.net.wifi.WifiManager import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import android.text.format.Formatter class MainActivity : AppCompatActivity() {    lateinit var button: Button    lateinit var textView: TextView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

How to pick an image from an image gallery on Android using Kotlin?

Azhar
Updated on 30-Nov-2020 04:15:19

9K+ Views

This example demonstrates how to pick an image from an image gallery 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.Intent import android.net.Uri import android.os.Bundle import android.provider.MediaStore import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    lateinit var button: Button    private val pickImage = 100    private var ... Read More

Advertisements