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


C# ListView.SetSelection方法代码示例

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


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

示例1: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			LayoutInflater.Factory = new TextFactoryManager();
			SetContentView (Resource.Layout.user_dashboard_list_result);

			pastBookingActivity = this;
			userDashBoardListView = FindViewById<ListView> (Resource.Id.user_dashboard_list_result);
			userDashBoardListView.ItemClick += OnListItemClick;
			userDashBoardListView.SetOnScrollListener (this);

			llProgressBar = FindViewById<LinearLayout> (Resource.Id.llProgressBar);
			llProgressBar.Visibility = ViewStates.Gone;

			var llButtonSegmented = FindViewById<LinearLayout> (Resource.Id.llButtonSegmented);
			var vLine = FindViewById<View> (Resource.Id.viewSegmented);
			var btnAll = FindViewById<Button> (Resource.Id.btnAll);
			var btnCompleted = FindViewById<Button> (Resource.Id.btnComplete);

			llButtonSegmented.Visibility = ViewStates.Visible;
			vLine.Visibility = ViewStates.Visible;
			btnAll.FocusableInTouchMode = true;
			isBtnAllSelected = true;

			btnAll.Click += (sender, e) => {
				if(btnAll.FocusableInTouchMode)
					return;
				isBtnAllSelected = true;
				btnAll.FocusableInTouchMode = true;
				btnAll.RequestFocus();
				btnAll.RequestFocusFromTouch();
				btnAll.SetTextColor(Resources.GetColor(Resource.Color.white));

				btnCompleted.FocusableInTouchMode = false;
				btnCompleted.SetTextColor(Resources.GetColor(Resource.Color.green_sky_landing));

				setDataOnSegmentButton();
				userDashBoardListView.SetSelection(iCurrentPosAll);
			};

			btnCompleted.Click += (sender, e) => {
				if(btnCompleted.FocusableInTouchMode)
					return;
				isBtnAllSelected = false;
				btnAll.FocusableInTouchMode = false;
				btnAll.SetTextColor(Resources.GetColor(Resource.Color.green_sky_landing));

				btnCompleted.RequestFocus();
				btnCompleted.RequestFocusFromTouch();
				btnCompleted.FocusableInTouchMode = true;
				btnCompleted.SetTextColor(Resources.GetColor(Resource.Color.white));

				setDataOnSegmentButton();
				userDashBoardListView.SetSelection(iCurrentPosCompleted);
			};

			setDataToListView ();
			TCNotificationCenter.defaultCenter.addObserver (this, constants.kDeleteFilePast, new TCSelector(onDeleteImagePast));
			TCNotificationCenter.defaultCenter.addObserver (this, constants.kNotifyUpdateBookingInfo, new TCSelector(onNotifyUpdateBookingInfo));
			TCNotificationCenter.defaultCenter.addObserver (this, Constants.kPostDeleteFileSuccess, new TCSelector (onDeleteImagePast));
		}	
开发者ID:borain89vn,项目名称:demo2,代码行数:61,代码来源:PastBookingActivity.cs

示例2: OnCreate

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

            SetContentView (Resource.Layout.Main);

            textToSpeak = FindViewById<EditText> (Resource.Id.textToSpeak);
            speechButton = FindViewById<Button> (Resource.Id.speechButton);
            speechItemListView = FindViewById<ListView> (Resource.Id.speechItemListView);

            speech = new TextToSpeech (this, this);
                        speech.SetLanguage (Java.Util.Locale.Default); //translate to default locale

            speechButton.Click += (object sender, EventArgs e) => {

                string text = textToSpeak.Text;

                if (!String.IsNullOrEmpty (text)) {
                    speech.Speak (text, QueueMode.Add, null);
                } else {
                                        Toast.MakeText (this, Resource.String.enter_text_to_speak, ToastLength.Short).Show ();
                }
            };

            speechItemListView.ChoiceMode = ChoiceMode.Single;

            if (speechItemListView != null) {
                speechItemListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                    textToSpeak.Text = items [e.Position];
                    speechItemListView.SetSelection (e.Position);
                                        this.InvalidateOptionsMenu ();
                };
            }

                        textToSpeak.TextChanged += (sender, e) => this.InvalidateOptionsMenu();
        }
开发者ID:mikebluestein,项目名称:TalkBot,代码行数:36,代码来源:MainActivity.cs

示例3: OnCreate


//.........这里部分代码省略.........
                        string url = "http://www.omdbapi.com/?s=" + movieTitle.Text + "&r=json" + "&page=" + pageNumber.ToString();
                        
                        // Fetch the weather information asynchronously, 
                        // parse the results, then update the screen:

                        results = await FetchDataMoviesAsync(url);
                        

                        if (results != null)
                        {
                            if (results.Response == "False")
                            {
                                listaFilm.SetAdapter(null);
                                DisplayAlert("Alert", "No results were found", "OK");
                            }
                            else
                            {
                                items = new List<string>();
                                items = results.Search.Select(x => x.Title + " (" + x.Year + ")").ToList();                              
                                if (Convert.ToInt16(results.totalResults) > 10)
                                    items.Add("Load more items...");

                               // Console.Out.WriteLine("vedere se funziona il parse : {0} {1} {2}", results.totalResults, results.Response, results.Error);

                                listaFilm.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);
                                
                            }
                        }
                    }
                    else
                    {
                        DisplayAlert("Alert", "You need to insert more than 1 character", "OK");
                    }
                }
                else
                {
                    DisplayAlert("Alert", "You need INTERNET CONNECTION", "OK");
                }

                

            };

            listaFilm.ItemClick += async (sender, e) =>
            {
                
                if (e.Position == (items.Count - 1) && pageNumber != (Convert.ToInt16(results.totalResults) % 10 == 0 ? Convert.ToInt16(results.totalResults) / 10 : (Convert.ToInt16(results.totalResults) / 10) + 1))
                {
                    if (pageNumber < (Convert.ToInt16(results.totalResults) % 10 == 0 ? Convert.ToInt16(results.totalResults) / 10 : (Convert.ToInt16(results.totalResults) / 10) + 1) - 1)
                    {
                        pageNumber++;
                        string url = "http://www.omdbapi.com/?s=" + movieTitle.Text + "&r=json" + "&page=" + pageNumber.ToString();
                        SearchResponse resultsNuovi = await FetchDataMoviesAsync(url);
                        results.Search.AddRange(resultsNuovi.Search);
                        //Console.Out.WriteLine("I nuovi risultati messi insieme {0}", JsonConvert.SerializeObject(resultsNuovi));
                     
                        List<string> itemsNew = new List<string>();
                        itemsNew = resultsNuovi.Search.Select(x => x.Title + " (" + x.Year + ")").ToList();
                     
                        items.RemoveAt(e.Position);
                        scrollNumber = items.Count();
                        items.AddRange(itemsNew);
                        items.Add("Load more items...");

                        listaFilm.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);
                       
                        listaFilm.SetSelection(scrollNumber);


                    }
                    else
                    if (pageNumber < (Convert.ToInt16(results.totalResults) % 10 == 0 ? Convert.ToInt16(results.totalResults) / 10 : (Convert.ToInt16(results.totalResults) / 10) + 1))
                    {
                        pageNumber++;
                        string url = "http://www.omdbapi.com/?s=" + movieTitle.Text + "&r=json" + "&page=" + pageNumber.ToString();
                        SearchResponse resultsNuovi = await FetchDataMoviesAsync(url);
                        results.Search.AddRange(resultsNuovi.Search);
                        
                        List<string> itemsNew = new List<string>();
                        itemsNew = resultsNuovi.Search.Select(x => x.Title + " (" + x.Year + ")").ToList();
                      
                        items.RemoveAt(e.Position);
                        items.AddRange(itemsNew);

                        listaFilm.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);

                    }
                }
                else {

                    Intent intent = new Intent(this, typeof(MovieDetails));
                    Console.Out.WriteLine("lunghezza di results : {0}", results.Search.Count());
                    intent.PutExtra("MovieId", results.Search[e.Position].imdbID);
                    this.StartActivity(intent);
                    
                }
            };


        }
开发者ID:Ellyuca,项目名称:Mobile-Computing---Moviepedia,代码行数:101,代码来源:MainActivity.cs

示例4: AddBarCodeItem

        private void AddBarCodeItem(Item prd )
        {
            double stqQty = 1;
            double uprice= Utility.GetUnitPrice (trd, prd);
            double taxval = prd.tax;
            double amount = Math.Round((stqQty * uprice),2);
            double netamount = amount;
            bool taxinclusice = prd.isincludesive;
            double taxamt = 0;
            if (taxinclusice) {
                double percent = (taxval/100) + 1;
                double amt2 =Math.Round( amount / percent,2,MidpointRounding.AwayFromZero);
                taxamt = amount - amt2;
                netamount = amount - taxamt;

            } else {
                taxamt = Math.Round(amount * (taxval / 100),2,MidpointRounding.AwayFromZero);
            }

            InvoiceDtls inv = new InvoiceDtls ();
            inv.invno = invno;
            inv.amount = amount;
            inv.icode = prd.ICode;
            inv.price = uprice;
            inv.qty = stqQty;
            inv.tax = taxamt;
            inv.taxgrp = prd.taxgrp;
            inv.netamount = netamount;
            inv.description = prd.IDesc;
            //int id = Convert.ToInt32 (ITEMUID);
            //inv..title = spinner.SelectedItem.ToString ();
            using (var db = new SQLite.SQLiteConnection (pathToDatabase)) {
                var list =db.Table<InvoiceDtls> ().Where (x => x.invno == invno && x.icode == prd.ICode).ToList ();
                if (list.Count > 0) {
                    list [0].qty = list [0].qty + 1;
                    stqQty = list [0].qty;
                    amount = Math.Round((stqQty * uprice),2);
                    netamount = amount;
                    if (taxinclusice) {
                        double percent = (taxval/100) + 1;
                        double amt2 =Math.Round( amount / percent,2,MidpointRounding.AwayFromZero);
                        taxamt = amount - amt2;
                        netamount = amount - taxamt;

                    } else {
                        taxamt = Math.Round(amount * (taxval / 100),2,MidpointRounding.AwayFromZero);
                    }
                    list [0].tax = taxamt;
                    list [0].amount =amount;
                    list [0].netamount = netamount;

                    db.Update (list [0]);
                }else db.Insert (inv);
            }

            listData = new List<InvoiceDtls> ();
            populate (listData);
            listView = FindViewById<ListView> (Resource.Id.invitemList);
            SetViewDlg viewdlg = SetViewDelegate;
            listView.Adapter = new GenericListAdapter<InvoiceDtls> (this, listData, Resource.Layout.InvDtlItemViewCS, viewdlg);
            listView.SetSelection (listView.Count - 1);
        }
开发者ID:mokth,项目名称:merpV3,代码行数:62,代码来源:InvItemActivity.cs


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