-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Caio Costa
committed
Nov 13, 2020
1 parent
9343082
commit 9873f00
Showing
3 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
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
25 changes: 24 additions & 1 deletion
25
app/src/main/java/br/com/caiodev/newmaterialdesigntest/MainActivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
package br.com.caiodev.newmaterialdesigntest | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.ContextCompat | ||
import com.google.android.material.chip.Chip | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
class MainActivity : AppCompatActivity(R.layout.activity_main) | ||
class MainActivity : AppCompatActivity(R.layout.activity_main) { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setChipListener(firstChip) | ||
setChipListener(chip) | ||
} | ||
|
||
private fun setChipListener(chip: Chip) { | ||
chip.apply { | ||
setOnCheckedChangeListener { _, isChecked -> | ||
if (isChecked) { | ||
setTextColor(ContextCompat.getColor(applicationContext, android.R.color.white)) | ||
} else { | ||
setTextColor(ContextCompat.getColor(applicationContext, android.R.color.black)) | ||
} | ||
} | ||
} | ||
} | ||
} |
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