l1 = (LinearLayout)findViewById(R.layout.activity_main);
Change to
l1 = (LinearLayout)findViewById(R.id.yourlinearlayoutidfromxml);
You should also post the stacktace along with the question as relevant info regarding crash is logged. Suspect NullpointerException
.
Also you have setContentView
twice for the same activity which is not a good design.
setContentView(R.layout.activity_main);
You already have
l1 = (LinearLayout)findViewById(R.id.yourlinearlayoutidfromxml);
You should remove
setContentView(l1);