Created
December 15, 2019 17:29
-
-
Save merttoptas/8b76107f5e018bb4ca026ec34a501ae8 to your computer and use it in GitHub Desktop.
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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
//Create a notes in list | |
val notes:List<Note> | |
val db:AppDatabase= Room.databaseBuilder(this,AppDatabase::class.java,"notes") | |
.allowMainThreadQueries() | |
.fallbackToDestructiveMigration() | |
.build() | |
//Get a notes | |
notes=db.notedao().getAllNotes() | |
//set adapter | |
recyclerview.layoutManager= LinearLayoutManager(this) | |
recyclerview.adapter=NoteAdapter(notes,this@MainActivity) | |
fab.setOnClickListener { | |
val intent= Intent(this,CreateNoteActivity::class.java) | |
startActivity(intent) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment