Skip to main content

Posts

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...

android kotlin - Distinct 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 btnDistinct = findViewById<Button>(R.id.btnDistinct) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = listOf("RED","GREEN","RED","BLUE", "PINK","BLUE","BLACK","B...

android kotlin - List groupBy 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 btnGroupBy = findViewById<Button>(R.id.btnGroupBy) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = listOf("RED","GREEN","YELLOW","MAGENTA", "PINK","WHITE","BLACK",...

android kotlin - joinToString 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 import java.util.* 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 btnSimple = findViewById<Button>(R.id.btnSimple) val btnJoinToString = findViewById<Button>( R.id.btnJoinToString) // make textview content scrollable textView.movementMethod = ScrollingMovementMethod() // Create a list with values val list = listOf("RED","GREEN...