Code example for ScrollView

Methods: addView, setVerticalScrollBarEnabled

0
    	textbefore2 = new TextView(this);
    	textbefore2.setTextColor(0xFF000000);
    	textbefore2.setText("");
        textbefore2.setTextSize(20f);
    	 
    	sv = new ScrollView(this);
    	sv.setVerticalScrollBarEnabled(true);
    	 
    	ll2 = new LinearLayout(this);
    	ll2.setOrientation(LinearLayout.VERTICAL);
    	 
        rb1 = new RadioButton(this);
        rb1.setTextColor(0xFF000000);
        rb1.setText("Series Circuit");
        rb1.setId(0);
         
        rb2 = new RadioButton(this);
        rb2.setText("Parallel Circuit");
        rb2.setTextColor(0xFF000000);
        rb2.setId(1);
         
        rg = new RadioGroup(this);
        rg.setOrientation(LinearLayout.HORIZONTAL);
        LinearLayout.LayoutParams layoutParams = new RadioGroup.LayoutParams(
                RadioGroup.LayoutParams.WRAP_CONTENT,
                RadioGroup.LayoutParams.WRAP_CONTENT);
        rg.addView(rb1, 0, layoutParams);
        rg.addView(rb2, 1, layoutParams);
        if(pors == 0)
        	rg.check(0);
        if(pors == 1)
        	rg.check(1);
    	 
    	text2 = new TextView(this);
    	text2.setTextColor(0xFF000000);
        text2.setGravity(Gravity.LEFT);
        text2.setText("Voltage (Volts)");
        text2.setTextSize(20f);
         
        volt = new EditText(this);
        if(voltage != -1.0)
        	volt.setText(Double.toString(voltage));
        else 
        	volt.setHint("Unknown");
        volt.setInputType(2);
         
        text3 = new TextView(this);
    	text3.setTextColor(0xFF000000);
        text3.setGravity(Gravity.LEFT);
        text3.setText("\nCurrent (Amperage)");
        text3.setTextSize(20f);
         
        amp = new EditText(this);
        if(current != -1.0)
        	amp.setText(Double.toString(current));
        else 
        	amp.setHint("Unknown");
        amp.setInputType(2);
         
        text4 = new TextView(this);
    	text4.setTextColor(0xFF000000);
        text4.setGravity(Gravity.LEFT);
        text4.setText("\nResistance (Ohms)");
        text4.setTextSize(20f);
         
        res = new EditText(this);
        if(resistance != -1.0)
        	res.setText(Double.toString(resistance));
        else 
        	res.setHint("Unknown");
        res.setInputType(2);
         
        text5 = new TextView(this);
        if(resistors == 0){
        	text5.setTextColor(0x00000000);
        	text5.setText("");
        } 
        if(resistors > 0){
        	text5.setTextColor(0xFF000000);
        	text5.setText("\nSelect Resistor Wiring:");
        } 
        text5.setTextSize(20f);
         
        if(resistors > 0){
        	for(int i = 0; i < resistors; i++){
        		String resistorstring = "\nResistor " + Integer.toString(i+1);
        		resistortext[i] = new TextView(this);
        		resistortext[i].setText(resistorstring);
        		resistortext[i].setTextColor(0xFF000000);
        		resistortext[i].setGravity(Gravity.LEFT);
        		resistortext[i].setTextSize(20f);
        		resistoredittext[i] = new EditText(this);
        		if(resistorvalues[i] != -1.0)
        			resistoredittext[i].setText(Double.toString(resistorvalues[i]));
        		else 
        			resistoredittext[i].setHint("Unknown");
        		resistoredittext[i].setInputType(2);
        	} 
        } 
         
        text6 = new TextView(this);
    	text6.setTextColor(0x00000000);
    	text6.setText("");
         
        addresistor = new Button(this);
    	addresistor.setText("Add a Resistor");
    	 
    	text7 = new TextView(this);
    	text7.setTextColor(0x00000000);
    	text7.setText("");
    	 
    	clear = new Button(this);
    	clear.setText("Reset Calculator");
         
        ll.addView(text1);
        ll.addView(calculate);
        ll.addView(textbefore2);
        ll.addView(sv);
        sv.addView(ll2);
        ll2.addView(text2);
        ll2.addView(volt);
        ll2.addView(text3);
        ll2.addView(amp);
        ll2.addView(text4);
Contextual code suggestions in your IDE  Get Codota for Java