Skip to main content

Posts

android kotlin - plusAssign and minusAssign example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnPlusAssign = findViewById<Button>(R.id.btnPlusAssign) val btnMinusAssign = findViewById<Button>(R.id.btnMinusAssign) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() btnList.setOnClickListener { // Create a list with values val list = mutableListOf("RE...

android kotlin - removeAll and retainAll example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnRemoveAll = findViewById<Button>(R.id.btnRemoveAll) val btnRetainAll = findViewById<Button>(R.id.btnRetainAll) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() btnList.setOnClickListener { // Create a list with values val list = mutableListOf("RED...

android kotlin - getOrElse and getOrNull example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnGetOrNull = findViewById<Button>(R.id.btnGetOrNull) val btnGetOrElse = findViewById<Button>(R.id.btnGetOrElse) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = mutableListOf("RED","GREEN","YELLOW",...

android kotlin - Sequence partition example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnPartition = findViewById<Button>(R.id.btnPartition) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = generateList() btnList.setOnClickListener { textView.text = "Employees:\n" // Iterate through the lis...

android kotlin - maxBy and maxWith example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnMaxBy = findViewById<Button>(R.id.btnMaxBy) val btnMaxWith = findViewById<Button>(R.id.btnMaxWith) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = generateList() btnList.setOnClickListener { textView.text = ...

android kotlin - distinctBy multiple fields example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnDistinctBy = findViewById<Button>(R.id.btnDistinctBy) val btnDistinctByFields = findViewById<Button>( R.id.btnDistinctByFields) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = generateList() btnList.setOnClickL...

android kotlin - distinctBy example

MainActivity.kt package com.cfsuman.kotlintutorials import android.os.Bundle import android.text.method.ScrollingMovementMethod import android.widget.Button 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) // get the widgets reference from XML layout val textView = findViewById<TextView>(R.id.textView) val btnList = findViewById<Button>(R.id.btnList) val btnDistinctBy = findViewById<Button>(R.id.btnDistinctBy) val btnDistinctByAge = findViewById<Button>( R.id.btnDistinctByAge) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = generateList() btnList.setOnClickListen...