Horizontal recycleView inside Vertical RecycleView - android

I want to make playstore like layout i.e Horizontal recycleView inside Vertical RecycleView, I have a parent list like:
[{"pid":1,"name":XYX},{"pid":2,"name":ABC}]
and child list as shown below when I pass pid=1
[{"cid":1,"name":WWW,"pid":1},{"cid":2,"name":RRR,"pid":1}]
and when I pass pid=2
[{"cid":1,"name":DDD,"pid":2},{"cid":2,"name":VVV,"pid":2}]
I want to make it dynamic because parent and child list size can change.
So where should I make the api call for Child list
Any Suggestion would be helpful

onBindViewHolder of the parent adapter

Related

How to make row list using recyclerView and card? Can I use Nested RecyclerView?

I'm trying to design a row list using RecyclerView like Android TV ↳ android.support.v17.leanback.widget.ListRow. I'm able to design list with title but not row list. Can anyone help me?
Please Follow this Link for
Recycer view like play store
Use Two RecyclerView Outer Recycler is vertical and Second horizontal recycler is item of first recycler View
All you need is to call mInnerRecycler.setNestedScrollingEnabled(false); on your inner RecyclerViews and use Horizontal scrollview as root of mInnerRecyclerView
Explanation:
RecyclerView has support for nested scrolling introduced in API 21 through implementing the NestedScrollingChild interface. This is a valuable feature when you have a scrolling view inside another one that scrolls in the same direction and you want to scroll the inner View only when focused.
In any case, RecyclerView by default calls RecyclerView.setNestedScrollingEnabled(true); on itself when initializing. Now, back to the problem, since both of your RecyclerViews are within the same ViewPager that has the AppBarBehavior, the CoordinateLayout has to decide which scroll to respond to when you scroll from your inner RecyclerView; when your inner RecyclerView's nested scrolling is enabled, it gets the scrolling focus and the CoordinateLayout will choose to respond to its scrolling over the outer RecyclerView's scrolling. The thing is that, since your inner RecyclerViews don't scroll vertically, there is no vertical scroll change (from the CoordinateLayout's point of view), and if there is no change, the AppBarLayout doesn't change either.
In your case, because your inner RecyclerViews are scrolling in a different direction, you can disable it, thus causing the CoordinateLayout to disregard its scrolling and respond to the outer RecyclerView's scrolling.
Notice:
The xml attribute android:nestedScrollingEnabled="boolean" is not intended for use with the RecyclerView, and an attempt to use android:nestedScrollingEnabled="false" will result in a java.lang.NullPointerException so, at least for now, you will have to do it in code.
RecyclerView can check View Type for return header or item. And use layout manager for manage how to item scrolling direction.
RecyclerView (vertical scrolling)
- item -> RecyclerView (horizontal scrolling) check view type is header or item with condition example : is object has type header
Ref : Google play store like interface using recycler view

How to show staggred gridImageView inside cardview in Recyclerview Case

I want to implement image recyclerView (Staggered layout manager) inside cardView which teh cardView is item on recyclerView. I have a question when I build. Shall I call recyclerView adapter class inside class ViewHolder? or making custom adapter class so that I can call at one activity class? or Any suggestion?
This design describes my output expectation
Create a Recycler view like always and with his adapter, in the layout of the item for the recycler just add an ImageView to set with the picture
In the layout of the MainActivity you can use of layout parent the CardView with orientation vertical, and inside you will add the recyclerView and the TextView, both with height 0dp, and you'll add a weight of 0.8 for the Recycler View and weight of 0.2 for the TextView
When you set in the java the adapter of RecyclerView, you need to say in Grid(2) for be just 2 column
and it's done, I hope this can help something

Dynamic grid layout in recycler view

I get the json with the header values as category.
I need to split those category as displayed in the image attached
Can any one suggest how to achieve this view using recyclerview
?
There is no need to create multiple RecyclerView as it can be done with a single one. You should create one RecyclerView. Inside its item's custom layout, your should add RadioButton, TextView and 'GridView' and
you should use GridView inside your list item as following
<GridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3"
/>
It will have three columns as needed and height as wrap_content so that it can be expanded as needed.
I have a solution.
If don't get it then just ignore this answer.
1) First take one parent Recyclerview Which will consist of other RecyclerView as you need.
2) Create main adapter which will handle parent RecyclerView in which your sub RecyclerViews will be loaded as RecyclerView items.
3) Create adapter for sub RecyclerView which will assign these grid items.
4) Set layout of main RecyclerView as Vertical by LinearLayoutManager.VERTICAL and in sub RecyclerView layout should be a GridLayout.
5) For layout item of main parent RecyclerView should be a layout file with a simple RecyclerView in it, and for sub RecyclerViews, layout should be this item you want.
I hope you get this.
For further queries, please ask.
Happy to help.
Thank you.

ExpandableListView inside ScrollView is showing only one item

When I use ExpandableListView inside ScrollView it will show only one item,It is not showing all items and also when selected items it will shows all child items.
If your parent layout contains more items. Then you have to fix the height of listview in form of some dp instead of wrap_content/match_parent, or use NestedScrollView.

How to implement Custom ScrollView Like listview?

I want to add my Listview in another scroll view but when i add it in scrollview in xml it show only one item.so i want to create custom scroll view so i can put it in another scrollview.
Things to take into account:
ScrollView can only have a single child. If you want to add more of them you have to put them inside another ViewGroup, then add it to the ScrollView.
ListView handles its own scrolling, you should never put it inside another ScrollView.
If what you need is to have a certain number elements, a list of items included, scroll together as a single entity, you have two options:
Do not use a ListView, but a vertical LinearLayout. It will work, but with this all your rows will be created at once and won't be recycled while scrolling, so you should only do this if you can be sure your list will have a limited number of items.
A better option is to use a ListView as your main ViewGroup and add to it every other element you need in the scroll as headers or footers.

Categories

Resources