Skip to content
Fabio Hellmann edited this page Feb 11, 2016 · 7 revisions

BasicListCard

BasicListCard is a Card that allows you to show a checkable list inside the card.

It also shows a title and a description.

V3

BasicListAdapter adapter = new BasicListAdapter(this);
adapter.add("Task 1");
adapter.add("Task 2");
adapter.add("Task 3");

return new Card.Builder(this)
		.setTag("LIST_CARD")
		.setDismissible()
		.withProvider(new ListCardProvider())
		.setLayout(R.layout.material_list_card_layout)
		.setTitle("List Card")
		.setDescription("Take a list")
		.setAdapter(adapter)
		.endConfig()
		.build();

V2

For title and description, you only need to call the setTitle(String title) and setDescription(String description) methods

BasicListCard card = new BasicListCard(context);
card.setTitle("Your title");
card.setDescription("Your description");

For adding items to the list, you can add them one by one, or add them at the same call:

card.addItem("Task 1");
card.addAllItems("Task 2", "Task 3");

In order to provide the simple check implementation (check-uncheck), you can use the following listener:

card.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        boolean checked = card.isItemChecked(card.getItems().get(position));

        card.setItemChecked(position, !checked);
    }
});

NOTE

This card was created by Fabio Hellmann