Code example for RelativeLayout

Methods: addView, setId

0
        }*/ 
    } 
     
    public RelativeLayout createCharityDisplay(String charityName, int id, int sliderStart)
    { 
    	RelativeLayout charityDisplay = new RelativeLayout(this);
    	charityDisplay.setId(id);
    	id += 4;
    	 
    	RelativeLayout.LayoutParams labelParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 
    			LayoutParams.WRAP_CONTENT);
    	RelativeLayout.LayoutParams percentParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 
    			LayoutParams.WRAP_CONTENT);
    	RelativeLayout.LayoutParams seekParams = new RelativeLayout.LayoutParams(335, 
    			LayoutParams.WRAP_CONTENT);
    	RelativeLayout.LayoutParams lockParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 
    			LayoutParams.WRAP_CONTENT);
    	TextView charityLabel = new TextView(this);
    	labelParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, id);
    	labelParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, id);
    	labelParams.setMargins(0, 10, 0, 10);
    	charityLabel.setText(charityName);
    	charityLabel.setTextSize(20);
    	charityLabel.setId(id);
    	charityDisplay.addView(charityLabel, labelParams);
    	TextView charityPercent = new TextView(this);
    	percentParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, id);
    	percentParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, id);
    	percentParams.setMargins(0, 0, 10, 0);
    	charityPercent.setText("%");
    	charityPercent.setTextSize(20);
    	charityDisplay.addView(charityPercent, percentParams);
    	SeekBar charitySeek = new SeekBar(this);
    	charitySeek.setId(id);
    	id += 4;
    	seekParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, id);
    	seekParams.addRule(RelativeLayout.BELOW, charityLabel.getId());
    	seekParams.setMargins(10, 52, 10, 0);
    	charitySeek.setProgress(sliderStart);
    	sliderValues.add(sliderStart);
    	charityPercent.setText("" + charitySeek.getProgress() + "%");
    	charityDisplay.addView(charitySeek, seekParams);
    	CheckBox charityLock = new CheckBox(this);
    	lockParams.addRule(RelativeLayout.RIGHT_OF, charitySeek.getId());
    	lockParams.setMargins(0, 30, 57, 0);
    	charityDisplay.addView(charityLock, lockParams);
    	 
    	charitySliders.add(charitySeek);
    	charityPercents.add(charityPercent);
    	charityLocks.add(charityLock);
    	charityLock.setOnCheckedChangeListener(new OnCheckedChangeListener()