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


C# ListView.GetChildAt方法代码示例

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


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

示例1: CreateBackGroundColors

 //        public void Bla()
 //        {
 //            ListView listviewAchievements = FindViewById<ListView>(Resource.Id.listViewAchievements);
 //
 //            for (int i = listviewAchievements.FirstVisiblePosition; i < listviewAchievements.LastVisiblePosition + 1; i++)
 //            {
 //                listviewAchievements.GetChildAt(i).SetBackgroundColor(Color.DarkGreen);
 //            }
 //        }
 public void CreateBackGroundColors(ListView listviewAchievements)
 {
     for (int i = listviewAchievements.FirstVisiblePosition; i < listviewAchievements.LastVisiblePosition; i++)
     {
         listviewAchievements.GetChildAt(i).SetBackgroundColor(Color.DarkGreen);
     }
 }
开发者ID:ZuydUniversity,项目名称:ProgramADroid,代码行数:16,代码来源:ActivityAchievements.cs

示例2: StartDownloadAsync

        public static async Task StartDownloadAsync(int position, String url, ListView listView)
        {
            if (ViewsDownloadInProgressByAudioId.ContainsKey (url))
            {
                return;
            }

            // Locate the the child view and update.
            var firstPostion = listView.FirstVisiblePosition - listView.HeaderViewsCount;
            var childIndex = position - firstPostion;
            if (0 <= childIndex && childIndex < listView.ChildCount)
            {
                var view = listView.GetChildAt (childIndex);
                var progressBar = view.FindViewById<ProgressBar> (Resource.Id.DownloadProgress);

                ViewsDownloadInProgressByAudioId.Add (url, view);

                var downloader = new AndroidAudioDownloader ();
                await downloader.CreateDownloadTask (url, progressBar).ContinueWith (task =>
                    {
                        if (!task.IsFaulted)
                        {
                            ViewsDownloadInProgressByAudioId.Remove(url);
                            Log.Debug (DEBUG_TAG, "Downloaded {0} bytes.", task.Result);
                        }
                    }
                );
            }
        }
开发者ID:puncsky,项目名称:DrunkAudible,代码行数:29,代码来源:AndroidAudioDownloader.cs

示例3: OnCreateView

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = new ListView(this.Activity);
            favorites = (MainActivity.databaseConnection.GetAllFavoriteCategoriesAsync().
                             Result).
                                    OrderByDescending(x => x.Updated).ToList();

            view.Adapter = new ArrayAdapter<string>(this.Activity,
                                                    Android.Resource.Layout.SimpleListItem1,
                                                    favorites.Select(x => x.CategoryValue).ToList());

            view.ItemLongClick += (sender, e) =>
            {
                PopupMenu menu = new PopupMenu(this.Activity, view.GetChildAt(e.Position));
                menu.Inflate(Resource.Menu.UnfavoriteMenu);
                menu.Show();

                menu.MenuItemClick += (se, args) =>
                {
                    var result = MainActivity.databaseConnection.DeleteFavoriteCategoryAsync(favorites.ElementAt(e.Position)).Result;
                    if (MainActivity.databaseConnection.StatusCode == Models.codes.ok && result)
                    {
                        lock (favorites)
                        {
                            Activity.RunOnUiThread(() =>
                            {
                                favorites.RemoveAt(e.Position);
                                view.Adapter = new ArrayAdapter<string>(this.Activity,
                                        Android.Resource.Layout.SimpleListItem1,
                                                                        favorites.Select(x => x.CategoryValue).ToList());
                            });
                        }
                    }
                    else
                    {
                        Toast.MakeText(this.Activity, "Something went wrong. We're sorry!", ToastLength.Short).Show();
                    }
                    Console.WriteLine(MainActivity.databaseConnection.StatusMessage);
                };
            };

            view.ItemClick += (sender, e) =>
            {
                var transaction = this.Activity.SupportFragmentManager.BeginTransaction();
                SearchOptionsFragment searchFragment = new SearchOptionsFragment();
                var cat = favorites.ElementAt(e.Position);
                searchFragment.Category = new KeyValuePair<string, string>(cat.CategoryKey, cat.CategoryValue);
                searchFragment.SearchLocation = this.SelectedLocation;

                transaction.Replace(Resource.Id.frameLayout, searchFragment);
                transaction.AddToBackStack(null);
                transaction.Commit();
            };

            return view;
        }
开发者ID:erdennis13,项目名称:EthansList,代码行数:56,代码来源:FavoriteCategoriesFragment.cs

示例4: OnCreate

		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.listview);

			// The following comment is the sample usage of ArraySwipeAdapter.
			//var adapterData = new [] {
			//	"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
			//	"DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
			//	"BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
			//	"BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"
			//};
			//listView.Adapter = new ArraySwipeAdapter (this, Resource.Layout.listview_item, Resource.Id.position, adapterData);

			listView = FindViewById<ListView> (Resource.Id.listview);
			adapter = new ListViewAdapter (this);
			listView.Adapter = adapter;
			adapter.Mode = Attributes.Mode.Single;
			listView.ItemClick += (sender, e) => {
				((SwipeLayout)(listView.GetChildAt (e.Position - listView.FirstVisiblePosition))).Open (true);
			};
			listView.Touch += (sender, e) => {
				Console.WriteLine ("ListView: OnTouch");
				e.Handled = false;
			};
			listView.ItemLongClick += (sender, e) => {
				Toast.MakeText (this, "OnItemLongClickListener", ToastLength.Short).Show ();
				e.Handled = true;
			};
			listView.ScrollStateChanged += (sender, e) => {
				Console.WriteLine ("ListView: OnScrollStateChanged");
			};
			listView.ItemSelected += (sender, e) => {
				Console.WriteLine ("ListView: OnItemSelected:" + e.Position);
			};
			listView.NothingSelected += (sender, e) => {
				Console.WriteLine ("ListView: OnNothingSelected:");
			};
		}
开发者ID:Dealtis,项目名称:oldDMS_3,代码行数:39,代码来源:ListViewExample.cs

示例5: OnCreateView

        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView (inflater, container, savedInstanceState);
            var view = inflater.Inflate (Resource.Layout.NavigationLayout, null, true);
            navigationListView = view.FindViewById<ListView> (Resource.Id.navigationListView);
            navigationStatus = view.FindViewById<Spinner> (Resource.Id.fragmentStatus);
            navigationStatusImage = view.FindViewById<ImageView> (Resource.Id.fragmentStatusImage);
            timerLayout = view.FindViewById<RelativeLayout> (Resource.Id.fragmentTimerTextLayout);
            navigationStatusLayout = view.FindViewById<LinearLayout> (Resource.Id.navigationStatusLayout);
            timer = view.FindViewById<ToggleButton> (Resource.Id.fragmentTimer);
            timerHours = view.FindViewById<TextView> (Resource.Id.fragmentHours);

            navigationStatusImage.SetImageResource (Resource.Drawable.HoldImage);
            var spinnerAdapter = new SpinnerAdapter<AssignmentStatus> (assignmentViewModel.AvailableStatuses, Activity, Resource.Layout.SimpleSpinnerItem);
            spinnerAdapter.TextColor = Color.White;
            navigationStatus.Adapter = spinnerAdapter;
            if (Assignment != null && !Assignment.IsHistory) {
                navigationStatus.ItemSelected += (sender, e) => {
                    var status = assignmentViewModel.AvailableStatuses [e.Position];
                    if (Assignment != null && Assignment.Status != status && Assignment.Status != AssignmentStatus.New) {
                        switch (status) {
                            case AssignmentStatus.Complete:
                                //go to confirmations screen
                                var currentPosition = navigationListView.SelectedItemPosition;
                                var confirmationPosition = Constants.Navigation.IndexOf ("Confirmations");
                                if (currentPosition != confirmationPosition) {
                                    navigationSelector.OnItemClick (navigationListView, navigationListView.GetChildAt (confirmationPosition), confirmationPosition, 0);
                                }
                                navigationStatus.SetSelection (assignmentViewModel.AvailableStatuses.ToList ().IndexOf (Assignment.Status));
                                break;
                            default:
                                Assignment.Status = status;
                                SaveAssignment ();
                                break;
                        }
                    }
                };
            }
            timerLayout.Visibility = ViewStates.Gone;

            var adapter = new NavigationAdapter (Activity, Resource.Layout.NavigationListItemLayout, Constants.Navigation);
            if (Assignment != null && Assignment.IsHistory) {
                adapter = new NavigationAdapter (Activity, Resource.Layout.NavigationListItemLayout, Constants.HistoryNavigation);
            }
            navigationListView.OnItemClickListener = navigationSelector;
            navigationListView.Adapter = adapter;

            timer.CheckedChange += (sender, e) => {
                if (e.IsChecked != assignmentViewModel.Recording) {
                    if (assignmentViewModel.Recording) {
                        assignmentViewModel.PauseAsync ();
                    } else {
                        assignmentViewModel.RecordAsync ();
                    }
                }
            };

            SetActiveAssignment ();

            return view;
        }
开发者ID:harouny,项目名称:prebuilt-apps,代码行数:61,代码来源:NavigationFragment.cs

示例6: FinishImageDownload

        void FinishImageDownload (ListView listView, int position, Person person, Bitmap image)
        {
            images [person.Id] = image;
            imageDownloadsInProgress.Remove (person.Id);

            var personItem = (position < items.Count) ?
                            items [position] as PersonItem :
                            null;

            if (personItem != null && personItem.Person == person) {

                var firstPostion = listView.FirstVisiblePosition - listView.HeaderViewsCount;
                var childIndex = position - firstPostion;

                if (0 <= childIndex && childIndex < listView.ChildCount) {
                    var view = listView.GetChildAt (childIndex);
                    var imageButton = view.FindViewById<ImageButton> (Resource.Id.ImageButton);
                    imageButton.SetImageBitmap (image);
                }
            }
        }
开发者ID:EminosoftCorp,项目名称:prebuilt-apps,代码行数:21,代码来源:PeopleGroupsAdapter.cs

示例7: OnCreate

        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Waiter_Table_Selection);
            string tableURL = "http://54.191.98.63/tables.php";
            JsonValue json = await JsonParsing<Task<JsonValue>>.FetchDataAsync(tableURL);
            
            List<Waiter_Table_Selection_List> parsedData = JsonParsing<Waiter_Table_Selection_List>.ParseAndDisplay(json);

            mItems = parsedData;
            mListView = FindViewById<ListView>(Resource.Id.Waiter_Table_Selection_ListView);
            

            Waiter_Table_Selection_ListViewAdapter adapter = new Waiter_Table_Selection_ListViewAdapter(this, parsedData);
            mListView.Adapter = adapter;

            var logout = FindViewById<Button>(Resource.Id.LogOut_Waiter_Table_Selection);
            logout.Click += (sender, e) =>
            {
                SetContentView(Resource.Layout.LoginScreen);
                Android.Widget.Toast.MakeText(this, "Logged Out Successfully", Android.Widget.ToastLength.Short).Show();
                StartActivity(typeof(LoginScreen));
            };

            var fab = FindViewById<FloatingActionButton>(Resource.Id.Waiter_Table_Selection_fab);
            fab.AttachToListView(mListView);
            fab.Click += (object sender, EventArgs args) =>
            {
                string strToDB = "";
                for (int i = 0; i < mListView.Count; i++) {
                    Console.WriteLine("list count = " + mListView.Count);
                    View rowView = mListView.GetChildAt(i);
                    if (rowView != null) {
                        TextView txtTable = rowView.FindViewById<TextView>(Resource.Id.Waiter_Table_Selection_Txt_Table);
                        CheckBox checkTable = rowView.FindViewById<CheckBox>(Resource.Id.Waiter_Table_Selection_checkBox);
                        Console.WriteLine(checkTable.Checked);
                        
                        if (checkTable.Checked)
                        {
                            WaiterPortal.Selecttable.Add(new WaiterPortal_List() { selectedtable = txtTable.Text });

                            pubnub.Subscribe<string>(
                        txtTable.Text,
                        DisplaySubscribeReturnMessage,
                        DisplaySubscribeConnectStatusMessage,
                        DisplayErrorMessage
                        );
                            strToDB = strToDB + txtTable.Text.ToString() + ",";
                        }
                    }
                }
                if(strToDB.Length != 0)
                {     
                strToDB = strToDB.Remove(strToDB.Length - 1);
                }
                
                Console.WriteLine("~~~~~~~~~~~~ " + strToDB);

                var webClient = new WebClient();
                Console.WriteLine("~~~~~~~~~~~~ "  + strToDB);
                TableURL = TableURL + strToDB;
                webClient.DownloadString(TableURL);
                this.Finish();
                StartActivity(typeof(WaiterPortal));
            };

        }
开发者ID:pchmura,项目名称:Munch,代码行数:67,代码来源:Waiter_Table_Selection_Activity.cs

示例8: FinishImageDownload

        void FinishImageDownload (ListView listView, int position, IIconAndTitleItem audio, Bitmap image)
        {
            _images [audio.Id] = image;
            _imageDownloadsInProgress.Remove (audio.Id);

            // Locate the the child view and update.
            var firstPostion = listView.FirstVisiblePosition - listView.HeaderViewsCount;
            var childIndex = position - firstPostion;
            if (0 <= childIndex && childIndex < listView.ChildCount)
            {
                var view = listView.GetChildAt (childIndex);
                var imageView = view.FindViewById<ImageView> (Resource.Id.Icon);
                imageView.SetImageBitmap (image);
            }
        }
开发者ID:puncsky,项目名称:DrunkAudible,代码行数:15,代码来源:IconAndTitleItemListAdapter.cs


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