Search code examples
c#xamarin.androidonclicklistener

OnItemClickListener - Error: There is no argument given that corresponds


Could you explain me what is wrong with this code?

 private void HandleEvents()
    {
        mListView.ItemClick += mListView_ItemClick;
    }

    void mListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
    {

        mListView_OnItemClickListener();
    }

    void mListView_OnItemClickListener(AdapterView parent, View view, int position, long id)
    {
        Testo.Text = (parent.GetItemIdAtPosition(position).ToString());
    }

I get this error:

There is no argument given that corresponds to the required formal parameter 'parent' of 'MainActivity.mListView_OnItemClickListener(AdapterView, View, int, long)'

Thanks!


Solution

  • I think you can use

    AdapterView.ItemClickEventArgs
    

    you should have

    e.Position
    

    that should give you the Selected Position in "fermate".

    So you can use something like

    void mListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
    {
    
        Testo.Text = fermate[e.Position];
    }