Created
June 25, 2017 02:59
-
-
Save dharmakshetri/89ef0617cec06d2d3270f07b5eae2df0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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