[Solved] LinearLayout findViewById problem – crash
my problem is probably pretty simple.
I have defined a LinearLayout in my layout.xml file and want to set the background drawable in code.
layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linlay"
android:orientation="vertical"
android:layout_width="fill_parent">
</LinearLayout>
.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ln = (LinearLayout) this.findViewById(R.id.linlay);
setContentView(ln);
ln.setBackgroundDrawable(getResources().getDrawable(R.drawable.wallpaper));
}
If I run the app it says the application has stopped unexpectedly.
any ideas?
Read more here: Source link