Found 417 Articles for Kotlin

How to make a GridLayout fit screen size in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 12:28:43

475 Views

This example demonstrates how to make a GridLayout fit screen size in Android using Kotlin.Step 1 − Create a new project in a new projectStep 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.Gravity import android.widget.GridLayout import android.widget.ImageView import android.widget.TableLayout import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       ... Read More

How do we set the input type for an Android EditText programmatically using Kotlin?

Azhar
Updated on 18-Aug-2020 12:25:31

1K+ Views

This example demonstrates how to set the input type for an Android EditText programmatically 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.text.InputType import android.view.View import android.widget.EditText class MainActivity : AppCompatActivity() {    private lateinit var editText: EditText    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ... Read More

How to bring an activity to the foreground i.e. top of stack using Kotlin?

Azhar
Updated on 18-Aug-2020 12:23:32

384 Views

This example demonstrates how to bring an activity to the foreground i.e. top of stack 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 projectStep 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 androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val i = Intent(this, NewActivity::class.java) ... Read More

How to use search functionality in custom listview in Android using kotlin?

Azhar
Updated on 18-Aug-2020 12:20:54

600 Views

This example demonstrates how to use search functionality in custom listview in Android 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.os.Bundle import android.text.Editable import android.text.TextWatcher import android.widget.ArrayAdapter import android.widget.EditText import android.widget.ListView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var listView: ListView    var months: ArrayList = ArrayList()    var arrayAdapter: ArrayAdapter? = null    lateinit var ... Read More

How to send HTML email using Android App using Kotlin?

Azhar
Updated on 18-Aug-2020 12:18:23

656 Views

This example demonstrates how to send HTML email using 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.net.Uri import android.os.Bundle import android.text.Html import android.view.View import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"    }    fun ... Read More

How can we get the current language selected in the Android device using Kotlin?

Azhar
Updated on 18-Aug-2020 12:15:10

804 Views

This example demonstrates how to get the current language selected in the Android device 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 java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val textView: ... Read More

How can I set an ImageView's width and height programmatically in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 12:13:31

3K+ Views

This example demonstrates how to set an ImageView's width and height 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.os.Bundle import android.widget.ImageView import android.widget.RelativeLayout import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val relativeLayout: RelativeLayout = findViewById(R.id.relativeLayout)   ... Read More

How to use the recyclerview with a database in Android using Kotlin?

Azhar
Updated on 18-Aug-2020 12:11:00

2K+ Views

This example demonstrates how to use the recyclerview with a database 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.text.TextUtils import android.view.LayoutInflater import android.view.View import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView class MainActivity : AppCompatActivity() {    private lateinit var dataBase: SqliteDatabase    override fun onCreate(savedInstanceState: Bundle?) { ... Read More

How to properly highlight selected items on Android RecyclerView using Kotlin?

Azhar
Updated on 18-Aug-2020 12:00:25

800 Views

This example demonstrates how to properly highlight selected items on Android RecyclerView 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 androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val recyclerView: RecyclerView = findViewById(R.id.recyclerView)   ... Read More

How to set the margin of ImageView programmatically in Android using Kotlin ?

Azhar
Updated on 18-Aug-2020 11:52:32

5K+ Views

This example demonstrates how to set the margin of ImageView 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.os.Bundle import android.widget.ImageView import android.widget.RelativeLayout import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var imageView: ImageView    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       ... Read More

Advertisements