How to create implement grouped checkbox on action menu xamarin android?

J. Joe

Action_menu

<?xml version="1.0" encoding="utf-8" ?> 
<menu xmlns:android="http://schemas.android.com/apk/res/android">

 <item
      android:id="@+id/menu_share"
      android:icon="@drawable/ic_search_white_24dp"
      android:showAsAction="ifRoom"
      android:title="Search"

      />

  <item
      android:id="@+id/menu_settings"
      android:showAsAction="never"
      android:orderInCategory="100"
      android:title="Setting"
      />
      <group android:checkableBehavior="single">
        <item android:id="@+id/selecta"
            android:title="Top 50"
            android:checked="true"
            android:actionViewClass="android.widget.checkbox"
            android:showAsAction="always"/>
        <item android:id="@+id/selectb"
            android:title="New &amp; hot"
            android:actionViewClass="android.widget.checkbox"
            android:showAsAction="always"/>
      </group>

</menu>
public override bool OnOptionsItemSelected (IMenuItem item) 
        {
            switch (item.ItemId) 
            {
            case Android.Resource.Id.Home:
                drawerLayout.OpenDrawer (Android.Support.V4.View.GravityCompat.Start);
                return true;
            case Android.Resource.Id.selecta:
                item.SetChecked (true);
                return true;
            case Android.Resource.Id.selectb:
                item.SetChecked (true);
                return true;
            }
            return base.OnOptionsItemSelected (item);
        }

        // Add options menu on toolbar


        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate (Resource.Menu.Action_menu, menu);
            return base.OnCreateOptionsMenu (menu);
        }

I want them such as below picture

enter image description here

I've a problem when i was adding Check box on Action Bar, it is not showing Check box on Action Bar

  • Errors: selecta,b does not contain a definition for ....
  • It don't see any id into Action_menu.xml

enter image description here

wishmaster

You have a typo in your XML layout. For your checkbox item It should be :

android:actionViewClass="android.widget.CheckBox"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how can I create this type of menu and call on Hover action in android?

What is the name of this android menu and how to implement it

How to implement android custom popup menu?

How to create checkbox in xamarin forms

How to hide menu item in android action bar?

How to implement push notification for xamarin android

Android: How to create options menu outside action/tool bar

How to get selected dynamic checkbox in xamarin android

How to implement an Alert box in xamarin forms android

How to implement swipe to delete action for listview/recyclerview in Xamarin Android native project

How to implement Certificate Transparency for Xamarin.Android

Xamarin Android: How to create a combobox

How to create a questionnaire grouped by category in Xamarin?

How to implement input checkbox's checked action?

How to create a Checkbox object in Android Studio with its own Action Listener

Create android action bar - How to?

how to add action dynamically for multiple checkbox on android?

How to create a checkbox menu with name of files in alphabetical order?

Android - How to hide the Menu Button in Action Bar

How to implement popup menu on a listview in android

How to create a menu in android in Eclips?

How to create Xamarin Menu Item

how to create Custom action menu with animation

Option menu checkbox android

How to implement an Android Service in Xamarin.Forms

Checkbox Size Xamarin Android

Xamarin Android: how to implement a ViewModelProvider factory?

How to implement Local Push notification in Xamarin Android

how to Create Slide up Menu in Xamarin.Android