daniel-stoneuk / material-about-library

Makes it easy to create beautiful about screens for your apps
Apache License 2.0
1.12k stars 140 forks source link

change data of the cards #80

Closed Xiphoray closed 6 years ago

Xiphoray commented 6 years ago

if i want to change some datas of the cards or Items after they have been built, what should i do?

daniel-stoneuk commented 6 years ago

Hi! The recent release means that changing the data of the cards is more efficient and effective as before.

The ExampleMaterialAboutFragment has an example of "dynamic items".

final MaterialAboutActionItem item = new MaterialAboutActionItem.Builder()
            .text("Dynamic UI")
            .subText(subText)
            .icon(new IconicsDrawable(c)
                    .icon(CommunityMaterial.Icon.cmd_refresh)
                    .color(ContextCompat.getColor(c, R.color.mal_color_icon_dark_theme)
                    ).sizeDp(18))
            .build();
item.setOnClickAction(new MaterialAboutItemOnClickAction() {
    @Override
    public void onClick() {
        item.setSubText("Random number: " + ((int) (Math.random() * 10)));
        refreshMaterialAboutList();
    }
});

Note the refreshMaterialAboutList(); method that updates the view.