当前位置: 首页>>代码示例>>C#>>正文


C# ListView.SetItemChecked方法代码示例

本文整理汇总了C#中ListView.SetItemChecked方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.SetItemChecked方法的具体用法?C# ListView.SetItemChecked怎么用?C# ListView.SetItemChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListView的用法示例。


在下文中一共展示了ListView.SetItemChecked方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SelectLocation);

            _locationItems = LocationFileWorker.GetLocationsFromCsvFile(Assets);

            _adapter = new SelectLocationAdapter(this, _locationItems);
            _myListView = FindViewById<ListView>(Resource.Id.list_view);
            _myListView.Adapter = _adapter;
            _inputSearch = FindViewById<EditText>(Resource.Id.inputSearch);
            _inputSearch.TextChanged += InputSearchOnTextChanged;

            var applyBtn = FindViewById<Button>(Resource.Id.Apply_btn);
            applyBtn.Click += applyBtn_Click;

            _myListView.ChoiceMode = ChoiceMode.Single;
            _myListView.ItemClick += lv_ItemClick;

            if (!String.IsNullOrEmpty(Settings.CityName))
            {
                int previouslySelectedIndex = _locationItems.FindIndex(i => i.CityName == Settings.CityName);
                _myListView.SetItemChecked(previouslySelectedIndex, true);
            }
            else
                _myListView.SetItemChecked(0, true);
        }
开发者ID:EAbychkov,项目名称:AlarmApp,代码行数:27,代码来源:SelectLocationActivity.cs

示例2: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SoundSelection);
            _items = new List<SoundItem>();
            _selectSoundListView = FindViewById<ListView>(Resource.Id.selectSound);
            _selectSoundListView.ChoiceMode = ChoiceMode.Single;

            var applyBtn = FindViewById<Button>(Resource.Id.Apply_btn);
            applyBtn.Click += ApplyBtnOnClick;

            var fields = typeof(Resource.Raw).GetFields();
            int index = 0;
            foreach (var fieldInfo in fields.ToList())
            {
                _items.Add(new SoundItem { Position = index, SoundName = fieldInfo.Name});
                index++;
            }

            _adapter = new SelectSoundAdapter(this, _items);
            _selectSoundListView.Adapter = _adapter;
            _selectSoundListView.ItemClick += selectSoundListView_ItemClick;

            if (!string.IsNullOrEmpty(Settings.WakeUpSound))
            {
                var previouslySelectedItemIndex = _items.FindIndex(i=> i.SoundName == Settings.WakeUpSound);
                _selectSoundListView.SetItemChecked(previouslySelectedItemIndex, true);
            }
        }
开发者ID:EAbychkov,项目名称:AlarmApp,代码行数:29,代码来源:SelectSoundActivity.cs

示例3: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            int calcNo = Intent.GetIntExtra("CalculationType",-1);

            SetContentView (Resource.Layout.PercentDrawer);

            drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
            drawerLayout.SetBackgroundColor(Android.Graphics.Color.AntiqueWhite);
            ColorDrawable colorDrawable = new ColorDrawable (Color.Black);
            this.ActionBar.SetBackgroundDrawable (colorDrawable);

            drawerToggle = new ActionBarDrawerToggle (this, drawerLayout, Resource.String.DrawerOpenDescription, Resource.String.DrawerCloseDescription);

            drawerLayout.SetDrawerListener (drawerToggle);

            drawerListView = FindViewById<ListView> (Resource.Id.drawerListView);
            drawerListView.Adapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1, calculationTitles);
            drawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => OnMenuItemClick(e.Position);
            drawerListView.SetItemChecked (calcNo, true);
            OnMenuItemClick (calcNo);

            ActionBar.SetDisplayHomeAsUpEnabled (true);
        }
开发者ID:vkroust,项目名称:Calculate-Percent,代码行数:25,代码来源:PercentDrawer.cs

示例4: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.CourseActivity);

            //code with drawer
            courseCategoryManager = new CourseCategoryManager();
            courseCategoryManager.MoveFirst();

               String displayCategoryTitle = courseCategoryManager.Current.CategoryTitle;

              // String displayCategoryTitle = DEFAULT_CATEGORY_TITLE;

            //Intent startupIntent = this.Intent;
            //if (startupIntent != null)
            //{
            //    String displayCategoryTitleExtra = startupIntent.GetStringExtra(DISPLAY_CATEGORY_TITLE_EXTRA);
            //    if (displayCategoryTitleExtra != null)
            //        displayCategoryTitle = displayCategoryTitleExtra;
            //}

            courseManager = new CourseManager(displayCategoryTitle);
            courseManager.MoveFirst();

            coursePagerAdapter = new CoursePagerAdapter(SupportFragmentManager, courseManager);
            viewPager = FindViewById<ViewPager>(Resource.Id.coursePager);
            viewPager.Adapter = coursePagerAdapter;

            //drawer

            drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);
            categoryDrawerListView = FindViewById<ListView>(Resource.Id.categoryDrawerListView);

            //categoryDrawerListView.Adapter =
            //    new CourseCategoryManagerAdapter(this, Android.Resource.Layout.SimpleListItem1, courseCategoryManager);

            categoryDrawerListView.Adapter =
                    new CourseCategoryManagerAdapter(this,Resource.Layout.CourseCategoryItem, courseCategoryManager);

            //android selected as default
            categoryDrawerListView.SetItemChecked(0, true);

            //click event for categories
            categoryDrawerListView.ItemClick += categoryDrawerListView_ItemClick;
        }
开发者ID:ngaruko,项目名称:XamarinDemo,代码行数:46,代码来源:CourseActivity.cs

示例5: OnCreate

        protected override void OnCreate(Bundle savedInstanceState)
        {
            _logging.WriteLine(Lib.Logging.MessageType.Information, "Starting application in MainActivity OnCreate method");
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            SetContentView(Resource.Layout.Main);
            drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);

            drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.DrawerOpenDescription, Resource.String.DrawerCloseDescription);

            drawerLayout.SetDrawerListener(drawerToggle);
            ActionBar.SetIcon(Android.Resource.Color.Transparent);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerListView = FindViewById<ListView>(Resource.Id.drawerListView);
            menuAdapter = new MenuAdapter (this);
            drawerListView.Adapter = menuAdapter;
            drawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => OnMenuItemClick(e.Position);
            var aboutFrag = menuAdapter.MenuItems.FirstOrDefault(x => x.Manager.GetType() == typeof(AboutFragment));
            var aboutPos = menuAdapter.MenuItems.IndexOf (aboutFrag);
            drawerListView.SetItemChecked(aboutPos, true);	// Highlight the About Fragment at startup
            OnMenuItemClick(aboutPos);                     // Load About Fragment at startup
        }
开发者ID:aaronlab,项目名称:Xamarin-Framework-Samples,代码行数:25,代码来源:MainActivity.cs

示例6: OnCreateView

        /// <inheritdoc />
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ZTnTrace.Trace(MethodBase.GetCurrentMethod());

            drawerListView = (ListView)inflater.Inflate(Resource.Layout.NavigationDrawer, container, false);

            drawerListView.ItemClick += (sender, e) => SelectItem(e.Position);

            var listItems = new[]
            {
                Resources.GetString(Resource.String.BattleTags),
                Resources.GetString(Resource.String.Settings)
            };

            drawerListView.Adapter = new ArrayAdapter<string>(
                Activity.ActionBar.ThemedContext,
                Android.Resource.Layout.SimpleListItemActivated1,
                Android.Resource.Id.Text1,
                listItems);

            drawerListView.SetItemChecked(currentSelectedPosition, true);

            return drawerListView;
        }
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:25,代码来源:NavigationDrawerFragment.cs

示例7: OnCreateView

        public override global::Android.Views.View OnCreateView(LayoutInflater inflater, ViewGroup
             container, Bundle savedInstanceState)
        {
            mDrawerListView = (ListView)inflater.Inflate(Resource.Layout.fragment_list_drawer, container, false);
            mDrawerListView.ItemClick += async (sender, e) =>
                SelectListItem (e.Position, true);
            
            mDrawerListView.SetAdapter(mListsAdapter);

            if (mCurrentSelectedPosition > mListsAdapter.GetCount())
            {
                mDrawerListView.SetItemChecked(mCurrentSelectedPosition, true);
            }

            return mDrawerListView;
        }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:16,代码来源:ListDrawerFragment.cs

示例8: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // load the main layout
            SetContentView(Resource.Layout.CourseActivity);

            courseCategoryManager = new CourseCategoryManager();
            courseCategoryManager.MoveFirst();
            String displayCategoryTitle = courseCategoryManager.Current.Title;

            //String displayCategoryTitle = DEFAULT_CATEGORY_TITLE;

            //Intent startupIntent = this.Intent;

            //if (startupIntent != null)
            //{
            //    String displayCategoryTitleExtra = startupIntent.GetStringExtra(DISPLAY_CATEGORY_TITLE_EXTRA);

            //    if (displayCategoryTitleExtra != null)
            //    {
            //        displayCategoryTitle = displayCategoryTitleExtra;
            //    }
            //}

            // create courseManager and move to start of courseList
            courseManager = new CourseManager(displayCategoryTitle);
            courseManager.MoveFirst();

            // coursePagerAdapter is used to link together the fragments and the data
            // SupportFragmentManager is a member of FragmentActivity, and allows us to manage fragments
            coursePagerAdapter = new CoursePagerAdapter(SupportFragmentManager, courseManager);

            // Sets the layout for each fragment
            viewPager = FindViewById<ViewPager>(Resource.Id.coursePager);

            viewPager.Adapter = coursePagerAdapter;

            drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawerLayout);

            categoryDrawerListView = FindViewById<ListView>(Resource.Id.categoryDrawerListView);

            categoryDrawerListView.Adapter = new CourseCategoryManagerAdapter(this, Resource.Layout.CourseCategoryItem, courseCategoryManager);

            categoryDrawerListView.SetItemChecked(0, true);

            categoryDrawerListView.ItemClick += categoryDrawerListView_ItemClick;
        }
开发者ID:sgccarey,项目名称:PluralsightXamarinCourses,代码行数:48,代码来源:CourseActivity.cs

示例9: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            SetTheme (Resource.Style.Theme_Sherlock);
            base.OnCreate (bundle);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            list = FindViewById<ListView> (Resource.Id.list);
            drawer = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
            adapter = new CustomAdapter (this, list_text);
            list.Adapter = adapter;
            fragA = new FragmentA ();
            fragB = new FragmentB ();
            list.ItemClick += (sender, e) => {
                ListView item = sender as ListView;
                int pos = item.CheckedItemPosition;
                TextView t = (TextView) e.View.FindViewById(Resource.Id.textView1);
                string mess = t.Text;
                Bundle args = new Bundle();
                args.PutString("message", mess);
                transaction = SupportFragmentManager.BeginTransaction();
                switch (pos){
                case 0:
                    if(!fragA.IsVisible){
                        fragA.Arguments = args;
                        transaction.Replace(Resource.Id.frame, fragA);
                    }
                    break;
                case 1:
                    if(!fragB.IsVisible){
                        fragB.Arguments = args;
                        transaction.Replace(Resource.Id.frame, fragB);
                    }
                    break;

                }
                transaction.Commit();
                list.SetItemChecked(pos, true);
                drawer.CloseDrawer(list);

            };

            mDrawerToggle = new Android.Support.V4.App.ActionBarDrawerToggle(this, drawer,  Resource.Drawable.ic_drawer, Resource.String.drawer_open, Resource.String.drawer_close)
            {
            };
            drawer.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetDisplayHomeAsUpEnabled (true);
            SupportActionBar.SetHomeButtonEnabled(true);
            // Get our button from the layout resource,
            // and attach an event to it
        }
开发者ID:sergeyfitis,项目名称:XamarinTest,代码行数:50,代码来源:MainActivity.cs

示例10: OnCreateView

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            mDrawerListView = (ListView) inflater.Inflate(Resource.Layout.fragment_navigation_drawer, container, false);
            mDrawerListView.SetItemChecked(mCurrentSelectedPosition, true);
            mDrawerListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => selectItem(e.Position);
            string[] title = new string[]
            {
                GetString(Resource.String.title_section1),
                GetString(Resource.String.title_section2),
                GetString(Resource.String.title_section3),
            };

            ArrayAdapter listAdapter = new ArrayAdapter(Activity, //this.getActionBar().ThemedContext,
                                           Android.Resource.Layout.SimpleListItemActivated1, Android.Resource.Id.Text1, title);
            mDrawerListView.SetAdapter(listAdapter);
            mDrawerListView.SetItemChecked(mCurrentSelectedPosition, true);
            return mDrawerListView;
        }
开发者ID:neelanu,项目名称:xamarin_samples,代码行数:18,代码来源:NavigationDrawerFragment.cs


注:本文中的ListView.SetItemChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。