单击一个按钮,我以编程方式创建一个文本视图并将它们添加到 flexboxlayout。为什么只添加了一个视图?
mButton.setOnClickListener(new View.OnClickListener() {
int i = 1;
@Override
public void onClick(View v) {
flexboxLayout.setFlexDirection(FlexDirection.ROW_REVERSE);
flexboxLayout.setFlexWrap(FlexWrap.WRAP);
flexboxLayout.setJustifyContent(JustifyContent.CENTER);
final TextViewR textViewR = new TextViewR(getApplicationContext(), "Text " + Integer.toString(i++)); //setting text here
FlexboxLayout.LayoutParams lp = new FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
lp.setOrder(1);
textViewR.setLayoutParams(lp);
flexboxLayout.addView(textViewR);
}
});