I have one Activity in that there are no Buttons but I have coded it in such a way that another Activity comes, now in this second A
I tried this code..hope helps to you..
1.layout_existed.xml
2.layout_toinfliate.xml
3.LayoutInflateDemo.java
public class LayoutInflateDemo extends Activity {
private LinearLayout layoutToAdd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_existed);
layoutToAdd = (LinearLayout) findViewById(R.id.existedlayout);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = LayoutInflater
.from(getApplicationContext());
View view = inflater.inflate(R.layout.layout_toinfliate, null);
layoutToAdd.addView(view);
}
});
}
}