Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ItemView extends ConstraintLayout {
- LinearLayout linearButtons;
- LinearLayout linearText;
- public ItemView(Context context, String name, String price, ArrayList<String> guests,
- ArrayList<String> checked, int id) {
- ...
- addView(linearText);
- addView(linearButtons);
- set.clone(this);
- set.connect(linearText.getId(), ConstraintSet.LEFT, this.getId(),
- ConstraintSet.LEFT, 8);
- set.connect(linearText.getId(), ConstraintSet.TOP, this.getId(),
- ConstraintSet.TOP, 8);
- set.connect(linearButtons.getId(), ConstraintSet.RIGHT, this.getId(),
- ConstraintSet.RIGHT, 8);
- set.connect(linearButtons.getId(), ConstraintSet.TOP, this.getId(),
- ConstraintSet.TOP, 8);
- }
- for (Item it:r.getItems()) {
- ItemView itemView = new ItemView(this, it.getName(), nf.format(it.getPrice()), dinerlist, it.getGuests(), i);
- ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT);
- itemView.setLayoutParams(params);
- vg.addV[enter image description here][1]iew(itemView);
- Log.d("ItemView Children: ", itemView.getWidth()+" "+itemView.getHeight());
- //add the view with 0dp width and height
- val layoutParams = ConstraintLayout.LayoutParams(0, 0)
- val view = View(context)
- view.id = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) View.generateViewId() else 1138
- parent.addView(view)
- //apply the default width and height constraints in code
- val constraints = ConstraintSet()
- constraints.clone(parent)
- constraints.constrainDefaultHeight(view.id, ConstraintSet.MATCH_CONSTRAINT_SPREAD)
- constraints.constrainDefaultWidth(view.id, ConstraintSet.MATCH_CONSTRAINT_SPREAD)
- constraints.applyTo(parent)
Add Comment
Please, Sign In to add comment