How to inflate View on layout, where all my ui elements which are on layout should be visible.
Am trying this lines but it is not working am not able to see my background image, button and other images.
MyView view1=new MyView(this);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view1= (MyView) inflater.inflate(R.layout.main, null);
Please help.. Thanks in advance.
For what you are doing, use
The reason for not getting your view after inflating is that you need to add that View in the current View somewhere. Currently your inflated view is orphaned.