This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To chain these seven CardViews in a ConstraintLayout with equal distance between them, you can use chains and guidelines. Here's how you can do it: | |
1. First, define horizontal guidelines to create equal spacing between the CardViews. Add these lines to your ConstraintLayout: | |
```xml | |
<androidx.constraintlayout.widget.Guideline | |
android:id="@+id/guideline_start" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:orientation="vertical" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(){ | |
var fn: (a: Int, b: Int) -> Int = ::sum | |
var lambdaOne: (Int,Int)->Int = {x: Int, y: Int -> x+y } | |
multiLineLambda() | |
val singleParameter: (Int) -> (Int) = {x: Int -> x * x} | |
val simplifySingleParameter: (Int) -> (Int) = {it * it} | |
calculator(1, 2){a,b -> a +b} //if lambda expression is the last parameter of a function | |
//you can write that lamdba in above way also. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//navigation | |
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" | |
implementation "androidx.navigation:navigation-ui-ktx:$nav_version" | |
//room database | |
implementation "androidx.room:room-ktx:$room_version" | |
kapt "androidx.room:room-compiler:$room_version" | |
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.coroutinelearning.retrofits | |
import com.example.coroutinelearning.entity.Root | |
import retrofit2.Response | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface ApiInterface { | |
@GET("/api/users") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.coroutinelearning.retrofits | |
import com.example.coroutinelearning.entity.Root | |
import retrofit2.Response | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface ApiInterface { | |
@GET("/api/users") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.coroutinelearning.retrofits | |
import com.example.coroutinelearning.entity.Root | |
import retrofit2.Response | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface ApiInterface { | |
@GET("/api/users") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.coroutinelearning.retrofits | |
import com.example.coroutinelearning.entity.Root | |
import retrofit2.Response | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface ApiInterface { | |
@GET("/api/users") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun saveUserDetailToDB() { | |
val name = binding.txtName.text.toString() | |
var mobNo = binding.txtMobNo.text.toString() | |
mobNo = mobNo.addMobileExtension() //extension function | |
var user = User(name = name, mobileNumber = mobNo) | |
user = user.firstLetterCapital() //extension function | |
userViewModel.saveUserDetail(user) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.coroutinelearning.entity | |
sealed class Employee //there is no need of {}, its optional | |
//if you use {}, u have to call class with use of Employee class, like Employee.Manager from fragment/activity. else u will be | |
//able to directly call it. | |
data class Manager(val name: String, val age: Int, val team: List<String>) : Employee() | |
class SeniorDev(val name: String, val age: Int, val project: String) : Employee() | |
object JuniorDev : Employee() |
NewerOlder