Horizontal ListView in Android?


Question

Is it possible to make the ListView horizontally? I have done this Using gallery view, but the selected item comes to the center of the screen automatically. I don't want the selected item at the same spot I clicked. How can I Rectify this Problem? My Idea was to set the ListView with horizontal scroll. Share your idea?

1
212
6/25/2014 12:44:54 AM

Accepted Answer

As per Android Documentation RecyclerView is the new way to organize the items in listview and to be displayed horizontally

Advantages:

  1. Since by using Recyclerview Adapter, ViewHolder pattern is automatically implemented
  2. Animation is easy to perform
  3. Many more features

More Information about RecyclerView:

  1. grokkingandroid.com
  2. 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);
114
11/5/2016 3:38:04 PM

Paul doesn't bother to fix bugs of his library or accept users fixes. That's why I am suggesting another library which has similar functionality:

https://github.com/sephiroth74/HorizontalVariableListView

Update: on Jul 24, 2013 author (sephiroth74) released completely rewritten version based on code of android 4.2.2 ListView. I must say that it doesn't have all the errors which previous version had and works great!


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon