当前位置 : 主页 > 编程语言 > c++ >

动态加radioButton 及布局

来源:互联网 收集:自由互联 发布时间:2021-07-03
动态加组件,居中,padding margin, radiogroup 要重新remove 再加一下 LinearLayout.LayoutParams params= new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); params.setMargins(10,10,10,10); for(int i=0;i t
动态加组件,居中,padding margin, radiogroup 要重新remove 再加一下
LinearLayout.LayoutParams params= new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1);
            params.setMargins(10,10,10,10);

            for(int i=0;i< time.data.length;i++){
                AdPriceEntity.Price temp=time.data[i];

                RadioButton rb=(RadioButton)inflater.inflate(R.layout.comp_rb,null);

                rb.setText(temp.detail_time+"\n"+temp.detail_price);
                rb.setId(Integer.valueOf(i+5000));

                rb.setTag(R.id.tag_a,temp.detail_time);
                rb.setTag(R.id.tag_b,temp.detail_price);
                rb.setPadding(5,5,5,5); 

                if(i<3){
                    llPrice1.addView(rb,params);
                }else{
                    llPrice2.addView(rb,params);
                }

            }

            mrgMoney.removeAllViews();
            mrgMoney.addView(llPrice1);
            mrgMoney.addView(llPrice2);
网友评论