Skip to content

Instantly share code, notes, and snippets.

@dharmakshetri
Created June 25, 2017 02:59
Show Gist options
  • Save dharmakshetri/89ef0617cec06d2d3270f07b5eae2df0 to your computer and use it in GitHub Desktop.
Save dharmakshetri/89ef0617cec06d2d3270f07b5eae2df0 to your computer and use it in GitHub Desktop.
mRecyclerView.layoutManager = LinearLayoutManager(this)
mRecyclerView.addItemDecoration(SimpleDividerItemDecoration(this))
// specify an adapter (see also next example)
mRecyclerView.adapter = MovieAdapter(applicationContext,Utils.getMovies())
}
// choose the layout between Linear and Grid
fun typeLayout(view: View){
when(layout){
"list"-> {
Utils.toast(applicationContext,"grid", Toast.LENGTH_SHORT)
imageViewType.setImageResource(R.drawable.list)
mRecyclerView.layoutManager= GridLayoutManager(this, spanCount)
layout="grid"
}
"grid"->{
Utils.toast(applicationContext,"list", Toast.LENGTH_SHORT)
imageViewType.setImageResource(R.drawable.grid)
mRecyclerView.layoutManager = LinearLayoutManager(this)
layout="list"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment