To achieve this, you can use layoutinflater:
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.yourLayoutName, null);
this.theSpinner = (Spinner) viewToLoad.findViewById(R.id.Spinny);
this.setContentView(viewToLoad );
Hope this helps. for dialogue you can just change the context from this to
this.getParent()
source
share