littlewombat littlewombat - 1 year ago 155
Java Question

Clickable LinearLayout in android studio

I want to use LinearLayot as a button, actually I have:

LinearLayout Ll;
Ll = (LinearLayout) findViewById(;
Ll.setOnClickListener(new View.OnClickListener(){
public void onClick(View view) {

but it doesn't work, when I try to open this activity is warning "Unfortunately, app has stopped". Click should close activity and back to main, in "//action" I use "finish()" but there is the same problem.

Answer Source

If you look at your code.

You are calling


after the linearlayout binding with click listener.

move these as the first line of the OnCreate

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download