An extension for rendering larger data sets efficiently using
RecyclerView for AppInventor & Distros.
Event raised to create UI. Don’t bind any data to the UI here.
root : AndroidViewComponent
Event raised to bind data to UI.
root : AndroidViewComponent
position: Current position.
RecyclerListinside a layout.
Create component inside a layout. For more details see: Dynamic Components
Create components inside a layout using JSON template. See Creating Templates
Set properties of a component.
Returns the root AndroidViewComponent of a child component.
Find a component using tag inside a root component. Returns AndroidViewComponent.
Set unique id of a component.
Get unique id of a component.
Returns true if the given component is dynamic.
Scroll to position.
Get / Set data count.
Recycler layout managers.
Recycler snap helpers.
Use these blocks to define layout orientation of recycler list.
Get position of first and last partially and fully visible items.
We will create a simple project that renders buttons inside card. When a button is clicked, it shows snackbar with the id of the button.
- Lets start by initializing the recycler view inside ListContainer. We will use
GridLayoutManagerbecause we want to create multiple columns. If you want to create single coulmn lists, use
LinearLayoutManagerinstead. To create a Masonry Layout, use
StaggeredLayoutManager. Next we will use
NoSnapHelperas we don’t wan’t any snapping. Moreover, snapping only works with
LinearSnapHelperto snap items to center &
PagerSnapHelperto create a ViewPager snap effect. Next set reverse to false and set spanCount (Number of columns) to 3. Next set the count to 90.
We need to inflate our UI inside
OnCreateView. Remember: only create UI, don’t bind any data here. The parameter
rootis actually a
VerticalArrangement. You can style root view just as you would style a vertical arrangement. Now we will create components using
CreateComponentblock. It takes a layout in which you want to create view, the name of the component, a tag to identify the component inside root view and properties in either a dictionary block or a json string.
To get a component reference using the root view, use
GetComponentblock and pass it
rootview and tag of the desired component.
OnBindViewevent, we will bind data to the UI. Here we have access to the
position. Here we will set the position as text of the button by using
To handle click events on a component, it is recommended to set a unique id by joining component name with the position to that component using
SetUniqueIdblock so that you can access the
- Now we can handle click events using
Any Button.OnClickevent from
AnyComponentsection. First we will verify whether the click event was not already handled and the component is dynamic using
IsDynamicblock. Next we will save the uique id of button to
idvariable by using
GetUniqueIdblock. We will also create a position variable. To extract the position from unique id, we will replace the word
buttonfrom unique id. Now we can use this position to show a snackbar.
- AIX File: com.dreamers.recyclerlist.aix (78.5 KB)
- AIX File : Github