use of carbon.widget.Chip in project Carbon by ZieIony.
the class FlowLayoutActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flowlayout);
FlowLayout layout = (FlowLayout) findViewById(R.id.flowLayout);
Stream.of(layout.getViews()).filter(v -> v instanceof Chip).forEach(v -> {
final Chip chip = (Chip) v;
chip.setText(fruits.get((int) (Math.random() * fruits.size())));
if (Math.random() > 0.5) {
chip.setIconVisible(true);
String image = "http://lorempixel.com/100/100/people/#" + System.currentTimeMillis();
Picasso.with(this).load(image).into((ImageView) chip.getIconView());
} else {
chip.setIconVisible(false);
}
if (Math.random() > 0.5) {
chip.setRemovable(true);
chip.setOnRemoveListener(() -> {
chip.setOutAnimation(AnimUtils.Style.Fade);
chip.setVisibility(View.GONE);
});
} else {
chip.setRemovable(false);
}
});
}
Aggregations