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


C# EditText.Length方法代码示例

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


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

示例1: OnCreate

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

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);  
            
            mLinearLayout = FindViewById<LinearLayout>(Resource.Id.mainView);
            mTitleSectionLayout = FindViewById<LinearLayout>(Resource.Id.titleSection);
            mGetSectionLayout = FindViewById<LinearLayout>(Resource.Id.getSection);
            mListaLayout = FindViewById<ListView>(Resource.Id.listaFilm);

            mLinearLayout.Click += (sender, e) =>
            {
                InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService);
                inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None);
            };

            mTitleSectionLayout.Click += (sender, e) =>
            {
                InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService);
                inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None);
            };
            mGetSectionLayout.Click += (sender, e) =>
            {
                InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService);
                inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None);
            };

            movieTitle = FindViewById<EditText>(Resource.Id.titleText);
            listaFilm = FindViewById<ListView>(Resource.Id.listaFilm);
            Button searchMoviesButton = FindViewById<Button>(Resource.Id.getMoviesButton);

            searchMoviesButton.Click += async (sender, e) =>
            {
                InputMethodManager inputManager = (InputMethodManager)this.GetSystemService(Activity.InputMethodService);
                inputManager.HideSoftInputFromWindow(this.CurrentFocus.WindowToken, HideSoftInputFlags.None);

                pageNumber = 1;
                if (isConnected())
                {
                    if (movieTitle.Length() > 1)
                    {

                        // Get the title text  entered by the user and create a query.
                        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));
//.........这里部分代码省略.........
开发者ID:Ellyuca,项目名称:Mobile-Computing---Moviepedia,代码行数:101,代码来源:MainActivity.cs

示例2: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            editText = FindViewById<EditText>(Resource.Id.MyButton);
            txtLength = FindViewById<EditText>(Resource.Id.txtLength);
            var mTextWatcher = new TextWatcher(editText, txtLength);
            //editText.AddTextChangedListener(mTextWatcher);

            editText.AddTextChangedListener(mTextWatcher);
            editText.SetSelection(editText.Length()); // 将光标移动最后一个字符后面
        }
开发者ID:Yi-shion,项目名称:Xamarin,代码行数:12,代码来源:MainActivity.cs


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