1

I want to make a clickable LinearLayout. I already set the Layout to Clickable and Focusable, but how can I write code in mainActivity.cs like:

LinearLayout.ItemClick += LinearLayout_ItemClick;

void LinearLayout_ItemClick(Object sender, AdapterView.ItemClickEventArgs e)
    {
        //Do something...
    }

Because it says that a Layout doesn't have the clickable function!?

1 Answers1

2

Would it be layout.Click instead of layout.ItemClick?

ItemClick is intended for lists, and allows you to define the behaviour when clicking on the elements of those lists

Update :

Your argument will not be AdapterView.ItemClickEventArgs anymore, I have no pc right here but if you type .Click +=, visual studio's intellisense should suggest you to add a handler and would create it for you with the right type :-)

Hope it solves your problem!

AdricoM
  • 579
  • 4
  • 11
  • Now it says: "No overload for 'LinearLayout_Click' matches delegate 'EventHandler'" –  Jan 13 '18 at 23:52
  • Because your argument will not be AdapterView.ItemClickEventArgs – AdricoM Jan 13 '18 at 23:53
  • What would it be then? –  Jan 13 '18 at 23:54
  • I have no pc right here but if you type `.Click +=`, visual studio's intellisense should suggest you to add a handler and would create it for you with the right type :-) – AdricoM Jan 13 '18 at 23:56