How to write click event on listview items using C# for Flying-out menu

kamalsekharpradhankamalsekharpradhan USMember
edited August 2016 in Visual Studio

Hi,
I have requirement to do flying-out menu using Visual studio C# with xamrin android. I have done as per bwlow code. Now i want click event on the menu items. How to do as per my code or If you have better idea about to develop flying-out menu, please suggest me. I am completely new to this technology.

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Collections.Generic;

namespace Demo.Droid
{
[Activity(Label = "Demo.Droid", MainLauncher = true, Icon = "@drawable/cab")]
public class MainActivity : Activity
{

    string[] items;
    private List<string> mItems;
    private ListView mListView;
    Button imageButon;
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);
        mListView = FindViewById<ListView>(Resource.Id.menuListView);

        mItems = new List<string>();
        mItems.Add("Home");
        mItems.Add("Personal Details");
        mItems.Add("Contact");
        mItems.Add("Alert");
        ArrayAdapter<string> adaptor = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mItems);
        mListView.Adapter = adaptor;

    }
    static int counter = 0;
    [Java.Interop.Export("button_OnClick")]
    public void button_OnClick(View v)
    {

        if (counter % 2 == 0)
        {
            mListView.Visibility = ViewStates.Visible;
            counter++;
        }
        else
        {
            mListView.Visibility = ViewStates.Gone;
            counter++;
        }

Main.axml code---

<?xml version="1.0" encoding="utf-8"?>





    <ListView
        android:id="@+id/menuListView"
        android:layout_below="@+id/titleBarLinearLayout"
        android:background="#ff64bbf8"
        android:divider="#CFEBFF"
        android:dividerHeight="1dp"
        android:layout_marginLeft="0dp"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:visibility="gone"
        android:layout_row="4"
        android:layout_column="0" />

Sign In or Register to comment.