private void setViewData() {
radioGroup.removeAllViews();
int margin = ScreenUtil.dip2px(this, 14.0f);
int marginLeft = ScreenUtil.dip2px(this, 20.0f);
int paddingLeft = ScreenUtil.dip2px(this, 3.0f);
RadioGroup.LayoutParams layoutParams =
new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
RadioGroup.LayoutParams layoutParams1 =
new RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
layoutParams.setMargins(marginLeft, margin, margin, margin);
layoutParams1.setMargins(margin, 0, margin, 0);
int defaultId = -1;
for (int i = 0; i < messageList.size(); i++) {
RadioButton rb = new RadioButton(this);
rb.setMaxLines(2);
rb.setPadding(paddingLeft, 0, 0, 0);
rb.setText(messageList.get(i).relayMessage);
rb.setButtonDrawable(android.R.color.transparent);
rb.setTextColor(Color.parseColor("#555555"));
rb.setButtonDrawable(null);
rb.setCompoundDrawablePadding(margin);
rb.setEllipsize(TextUtils.TruncateAt.END);
Drawable drawable = getResources().getDrawable(R.drawable.relay_message_radio_selector);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
rb.setCompoundDrawables(drawable, null, null, null);
int generateId = generateViewId();
messages.put(generateId, messageList.get(i).relayMessage);
rb.setId(generateId);
if (i == 0) {
defaultId = generateId;
}
TextView view = new TextView(this);
view.setBackgroundColor(Color.parseColor("#dddddd"));
radioGroup.addView(rb, layoutParams);
radioGroup.addView(view, layoutParams1);
}
radioGroup.check(defaultId);
}