-2

sir a need to add a layout to another layout on click of a button.

Is it possible how.

surendra
  • 2,217
  • 7
  • 34
  • 42

2 Answers2

2

Example here: How to lay out Views in RelativeLayout programmatically?

Community
  • 1
  • 1
Bojan Radivojevic
  • 717
  • 3
  • 12
  • 23
1

It is. Add this code to the onClickListener of your button:

LinearLayout layout = new LinearLayout(...);

// init this layout here

RelativeLayout parentLayout = (RelativeLayout) findViewById(R.id.myLayout);
parentLayout.addView(layout);
Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103