Code example for ScrollView

Methods: addView, setLayoutParams, setVerticalScrollBarEnabled

0
	 *  
	 * @return the view created dynamically. 
	 */ 
	protected View createGraphOptionDialog() {
		LinearLayout outerContainer = new LinearLayout(this);
		ScrollView container = new ScrollView(this);
		container.setVerticalScrollBarEnabled(true);
		container.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
				Helper.convertDpToPx(200, this)));
		LinearLayout linear = new LinearLayout(this);
		linear.setOrientation(LinearLayout.VERTICAL);
		linear.setLayoutParams(new LinearLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		linear.setVerticalScrollBarEnabled(true);
 
		List<String> options = getGraphOptions();
		for (int cnt = 0; cnt < options.size(); cnt++) {
			CheckBox newRadioButton = new CheckBox(this);
			newRadioButton.setChecked(mGraphResource.get(cnt));
			newRadioButton.setText(options.get(cnt));
			newRadioButton.setTextSize(Helper.convertDpToPx(15, this));
			newRadioButton.setLayoutParams(new LayoutParams(
					LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
			newRadioButton
					.setOnCheckedChangeListener(new OnCheckedChangeListener() {
						public void onCheckedChanged(CompoundButton buttonView,
								boolean isChecked) {
							String text = (String) buttonView.getText();
 
							for (int i = 0; i < mGraphOptions.size(); i++) {
								if (text == mGraphOptions.get(i)) {
									mGraphResource.set(i, isChecked);
								} 
							} 
						} 
					}); 
			linear.addView(newRadioButton);
		} 
		container.addView(linear);
		outerContainer.addView(container);
		return outerContainer;
	} 
 
	/**