Horizontal ListView in Android?
As per Android Documentation RecyclerView
is the new way to organize the items in listview and to be displayed horizontally
Advantages:
- Since by using Recyclerview Adapter, ViewHolder pattern is
automatically implemented - Animation is easy to perform
- Many more features
More Information about RecyclerView
:
- grokkingandroid.com
- antonioleiva.com
Sample:
survivingwithandroid.com
Just add the below block to make the ListView
to horizontal from vertical
Code-snippet
LinearLayoutManager layoutManager= new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, false);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(layoutManager);
How to create a horizontal list view? Android
If you want to create horizontal list you can use:
1)RecyclerView
with GridLayoutManager.HORIZONTAL
or LinearLayoutManager.HORIZONTAL
2) HorizontalVariableListView
How to build a horizontal ListView with RecyclerView
Is there a better way to implement this now with RecyclerView now?
Yes.
When you use a RecyclerView
, you need to specify a LayoutManager
that is responsible for laying out each item in the view. The LinearLayoutManager
allows you to specify an orientation, just like a normal LinearLayout
would.
To create a horizontal list with RecyclerView
, you might do something like this:
LinearLayoutManager layoutManager
= new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false);
RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);
How to create an Horizontal List View inside of a Vertical List View?
Use a RecyclerView with Horizontal LinearLayout as a item view of vertical RecyclerView with Vertical LinearLayoutManager. Yeah if you are creating your views right now from the scratch, always use Recycler View instead of ListView onwards.
Related Topics
Google Maps Android API V2 - Interactive Infowindow (Like in Original Android Google Maps)
How to Install Google Play Services in a Genymotion Vm (With No Drag and Drop Support)
Horizontal Listview in Android
Recyclerview Inside Scrollview Is Not Working
Failed to Resolve: Com.Android.Support:Appcompat-V7:26.0.0
How to Close Android Application
How to Do Something Like a Flowlayout in Android
"Failed to Load Ad: 3" With Doubleclick
How to Define Dimens.Xml For Every Different Screen Size in Android
How to Detect Incoming Calls, in an Android Device
How to Display an Alert Dialog on Android
"Default Activity Not Found" on Android Studio Upgrade
How to Build a Horizontal Listview With Recyclerview
Android Take Screenshot of Surface View Shows Black Screen
How to Detect If Software Keyboard Is Visible on Android Device or Not