I am going to develop soccer app, and having following json response.(link)
I have two different class with different names, but with same properties or fields and want to display one same single RecyclerView
.
Here I have worldmatch and world having same fields like matchTime
, startTime
and endTime
. I have created pojo class using jsontopojo plugin.
Here is main things, I want to display worldmatch in position 0 and rest of other position world based on club. You can see more details in picture.
This has to be first tab(world) and similarly to other tab like Europe , Asia with respective similar pattern.
Tab1(World)
---------------position 0 (All match)------------------
|
| 930 1100 1130 and so on ( horizontal recyclerview)
|
-------------------------------------------
---------------position 1(Barcelona)------------------
|
| 1130 1230 1330 1430 and so on ( horizontal recyclerview)
|
-------------------------------------------
---------------position 2(Chelsea)------------------
|
| 1300 1400 1500 and so on ( horizontal recyclerview)
|
-------------------------------------------
.
.
.
so on
(vertical recyclerview)
Details explanation picture view:
I have two Recyclerview Adapter, first one is display clubname and pass the respective data to other recycler view which gonna display horizontal view with respetive matchTime.
Populated the Outer Recyclerview position 0, worldmatch data and it reflect all the others, how do i pass the populated both worldmatch and world data in same recyclerview and how to filter out all the tab.
Display matchTime field only from WorldMatch list in position 0 and World list in below 0.(horizontal recyclerview)
Any one have any idea, which is really helpful for me and highly appreciate any idea behind this. Thanks in advance.
A RecyclerView. ViewHolder class which caches views associated with the default Preference layouts. A ViewHolder describes an item view and metadata about its place within the RecyclerView. Adapter implementations should subclass ViewHolder and add fields for caching potentially expensive findViewById results.
onBindViewHolder. Called by RecyclerView to display the data at the specified position. This method should update the contents of the itemView to reflect the item at the given position. Note that unlike android.
You can have the worldMatch
as the header of your vertical RecyclerView
. You do not really need two different adapters for your RecyclerView
in your case. Just add the header in your RecyclerView
with the worldMatch
class will suffice.
If you want to take a look at how you will be going for adding a header or footer in your RecyclerView
, you might take a look at the answer here.
Once you are done with adding the worldMatch
as the header of your vertical RecyclerView
you will be passing the world
data in the adapter of your RecyclerView
and show them accordingly.
Let me know if you have any confusions.
It is possible. Now you can set the value to another class in response parsing time or setting Adapter time. I also did this way. For example:
setmatches(List<club.wordlWild> ww){
List<WorldWild> list = new ArrayList<>();
for(club.worlWide cw : ww){
WorldWild w = new WorldWild ();
w.setMatchTime(cw.getMatchtimie);
..
...// set values
list.add(w);
}
}
Now you can get add club.worlWide values to WorldWild. If you want change do vise versa.
I did something similar via a parent class to use in the adapter but in your case it might be possible to just have the same class for each match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With