Hi all I am trying to run the attached code to display a checkbox when I click on the buttons.
My program crashes though and I can not see why. Do you have any idea? Thank you, Sara package Dynamiclayout.example.com; import Dynamiclayout.example.com.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ScrollView; import android.widget.LinearLayout; import android.widget.Button; import android.widget.CheckBox; public class Dynamiclayout extends Activity { Button buttonGET,buttonPost; CheckBox checkbox1; LinearLayout ll = null; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { class clicker implements Button.OnClickListener { @Override public void onClick(View v) { if(v==buttonGET){ checkbox1 = new CheckBox (null); checkbox1.setText("I'm dynamic!"); ll.addView(checkbox1); } if(v==buttonPost){ checkbox1.setText("I'm very dynamic!"); ll.addView(checkbox1); } } } super.onCreate(savedInstanceState); setContentView(R.layout.main); ScrollView sv = new ScrollView(this); //LinearLayout ll = new LinearLayout(this); ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); buttonGET = new Button(this); buttonGET.setText("GET"); ll.addView(buttonGET); buttonGET.setOnClickListener(new clicker()); buttonPost = new Button(this); buttonPost.setText("POST"); ll.addView(buttonPost); buttonPost.setOnClickListener(new clicker()); this.setContentView(sv); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Dynamiclayout.java
Description: Binary data