Skip to main content

Posts

Showing posts from November, 2019

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