- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2041 Articles for Mobile Development
304 Views
This example demonstrates how to determine the size of an Android view at runtime 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 − Copy and paste an image (.png/.jpg/.jpeg) into res/drawableStep 4 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.View import android.view.ViewTreeObserver.OnGlobalLayoutListener import android.widget.ImageView import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { private lateinit var imageView: ImageView override fun onCreate(savedInstanceState: Bundle?) { ... Read More
2K+ Views
This example demonstrates how to disable copy/paste from/to EditText in the 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.ActionMode import android.view.Menu import android.view.MenuItem import android.widget.EditText 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
2K+ Views
This example demonstrates how to add calendar events 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.content.Intent import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" } fun addCalendarEvent(view: ... Read More
1K+ Views
This example demonstrates how to read a simple text file 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 − Create a new Android Resource directory (raw.xml) and add a text file in the res/rawStep 4 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.View import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.io.BufferedReader import java.io.IOException import java.io.InputStream import java.io.InputStreamReader class MainActivity ... Read More
495 Views
This example demonstrates how to animate the change of background color of a 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.graphics.Color import android.graphics.drawable.ColorDrawable import android.graphics.drawable.TransitionDrawable import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var textView: TextView lateinit var button: Button override fun onCreate(savedInstanceState: Bundle?) { ... Read More
870 Views
This example demonstrates how to delete SharedPreferences data for my 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.content.SharedPreferences import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var textView: TextView lateinit var tvAfterDelete: TextView lateinit var sharedPreferences: SharedPreferences lateinit var editor: ... Read More
2K+ Views
This example demonstrates how to start a Service at Boot Time 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 − Create a new kotlin class and add the following code in RunServiceOnBoot.ktimport android.app.Service import android.content.Intent import android.os.Handler import android.os.IBinder import android.util.Log import android.widget.Toast class RunServiceOnBoot : Service() { private val TAG = "MyService" private lateinit var handler: Handler private lateinit ... Read More
1K+ Views
This example demonstrates how to Check if Android EditText is empty 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.ktimport android.os.Bundle import android.text.TextUtils import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var editText: EditText lateinit var button: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) ... Read More
246 Views
This example demonstrates how to get free size of internal/external memory 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.os.Environment import android.os.StatFs import android.widget.TextView 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) title = ... Read More
732 Views
This example demonstrates how to set the ringtone in Android from 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.content.Intent import android.media.RingtoneManager import android.net.Uri import android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { lateinit var btn: Button lateinit var txtView: TextView override fun onCreate(savedInstanceState: Bundle?) { ... Read More