I want to create multiple horizontalgridview and each gridview have title above it. I already successfully made and the result is according what I want, but my app becomes so heavy.
My current view is like this:
I have a LinearLayout which contains a textview and a horizontalgridview. let's call it item_layout
I will dynamically add multiple item_layout to a custom LinearLayout (I named it SectionedView) in the main_layout. The code is roughly like this (not my real code):
public class SectionedView extends LinearLayout{
...
public void setData(ArrayList<Object> object){
for(Object o:object){
View view = ...
title = (TextView)view.findViewById(R.id.title);
gridView = (GridView)view.findViewById(R.id.content);
title.setText(o.getTitle());
adapter = new Adapter(o.getItems());
gridView.setAdapter(adapter);
addView(view);
}
}
...
}
That custom LinearLayout in the main_layout is located inside a ScrollView.
This is example of the main_layout
and this one is example of the LinearLayout inside main_layout(basically is the same with previous image).
My question is does anyone know better workaround for this, how, and why ? Thanks!
Edit: I am creating an Android TV app so I need to get focus for every item to navigate. but I have tried RecyclerView inside RecyclerView, the inner RecyclerView couldn't get focus :(
Aucun commentaire:
Enregistrer un commentaire