Posts

Showing posts with the label dynamic controls in android

Create Form Programmatically in Android

Image
Step: 1 create a new xml layout with scrollview and LinearLayout . We create child view dynamically through code , added to the LinearLayout. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <? xml version = "1.0" encoding = "utf-8" ?> < ScrollView xmlns: android = "http://schemas.android.com/apk/res/android" android: id = "@+id/scrollView" android: layout_width = "match_parent" android: layout_height = "match_parent" android: fillViewport = "false" android: scrollbars = "none" android: layout_margin = "16dp" > < LinearLayout android: id = "@+id/layout1" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical" ></ LinearLayout > </ ScrollView > Step: 2 create new Activity class 1 2 3 4 5 6 7

Dynamic Controls Creation in Android

Image
DynamicFieldsActivity.java import android.animation.LayoutTransition ; import android.app.Activity ; import android.content.Context ; import android.os.Bundle ; import android.view.LayoutInflater ; import android.view.View ; import android.view.View.OnClickListener ; import android.widget.Button ; import android.widget.EditText ; import android.widget.LinearLayout ; import android.widget.RadioButton ; import android.widget.RadioGroup ; import android.widget.TextView ; import android.widget.Toast ; public class DynamicFieldsActivity extends Activity { EditText textIn ; Button buttonAdd ; LinearLayout container ; Button buttonShowAll ; @Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ); setContentView ( R . layout . dynamicfields ); textIn = ( EditText ) findViewById ( R . id . textin ); buttonAdd = ( Button ) findViewById ( R . id . add ); container = ( LinearLayout ) findViewById ( R . id