I have this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layout = (LinearLayout) View.inflate(this, R.layout.main, null);
setContentView(layout);
s = (Spinner) findViewById(R.id.spinner1);
It throws a ClassCastException why is it?
If I do setContentView(R.layout.main) everything goes well. But i need to have the layout in a variable because I need it to use an advertsiment library. Is there a a way to inflate the XML and have the layout in an variable?
Thanks
Which line is throwing the ClassCastException?
Also you can use
setContentView(R.layout.main);then still use a normal find view by id call to get a reference to your root layout.as long as this comes after you’ve called setContentView() you should get returned a reference to your layout object that you can use however you wish.