hey guys need a little help........my intention is to develop an app which contains just a button... and on clicking it it must create another button on the screen dynamically.......
here's my code...
public void onClick(View v) {
// TODO Auto-generated method stub
Button bee=new Button(getBaseContext());
bee.setText("hello:");
RelativeLayout a;
a=(RelativeLayout)findViewById(R.layout.activity_main);
a.addView(bee,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
});
this code is error free but when executed says "unfortunately 'myapplication' has stopped"....
pls do help guys..( my sole aim is to create widgets dynamically ,hence tried dis program). if u have any other suggestions pls post nd comment
logcatfor the reason for your application crashing.