Skip to content

Instantly share code, notes, and snippets.

@Ahmad-Hamwi
Created September 24, 2021 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ahmad-Hamwi/f59f2ace61a02d076d632b02fd2fd55c to your computer and use it in GitHub Desktop.
Save Ahmad-Hamwi/f59f2ace61a02d076d632b02fd2fd55c to your computer and use it in GitHub Desktop.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initViews()
initTabLayout()
initRecycler()
}
private fun initViews() {
tabLayout = findViewById(R.id.tabLayout)
recyclerView = findViewById(R.id.recyclerView)
}
private fun initTabLayout() {
for (category in categories) {
tabLayout.addTab(tabLayout.newTab().setText(category.name))
}
}
private fun initRecycler() {
recyclerView.adapter = CategoriesAdapter(this, categories)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment