protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); if (!((GlobalvarsApp)this.Application).ISLOGON) { Finish (); } SetTitle (Resource.String.SHOWLOCATION); SetContentView (Resource.Layout.ShowLocation); pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH; latlng= Intent.GetStringExtra ("location") ?? ""; date = DateTime.Today; wv1= FindViewById<WebView> (Resource.Id.webView1); btnBack =FindViewById<Button> (Resource.Id.butBack); btnShow =FindViewById<Button> (Resource.Id.butMaP); txtdate = FindViewById<EditText> (Resource.Id.date); wv1.SetWebViewClient (new myWebView ()); imm = (InputMethodManager)GetSystemService(Context.InputMethodService); txtdate.Click += delegate(object sender, EventArgs e) { imm.HideSoftInputFromWindow(txtdate.WindowToken, 0); ShowDialog (DATE_DIALOG_ID1); }; btnShow.Click+= (object sender, EventArgs e) => { ShowMap(); }; btnBack.Click+= (object sender, EventArgs e) => { base.OnBackPressed(); }; // Create your application here }
public KeyboardService (IContextService contextService) { _contextService = contextService; _inputMethodManager = ((Context)_contextService.GetContext ()).GetSystemService (Context.InputMethodService) as InputMethodManager; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); if (!((GlobalvarsApp)this.Application).ISLOGON) { Finish (); } SetTitle (Resource.String.STOCKSUMMARY); pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH; SetContentView (Resource.Layout.ItemStockList); imm = (InputMethodManager)GetSystemService(Context.InputMethodService); dateSearch = DateTime.Today; date = DateTime.Today; populate (listData); listView = FindViewById<ListView> (Resource.Id.ICodeList); txtSearch= FindViewById<EditText > (Resource.Id.txtSearch); Button butInvBack= FindViewById<Button> (Resource.Id.butICodeBack); Button butDate= FindViewById<Button> (Resource.Id.butDate); butDate.Click += delegate(object sender, EventArgs e) { //imm.HideSoftInputFromWindow(frd.WindowToken, 0); ShowDialog (DATE_DIALOG_ID1); }; butInvBack.Click += (object sender, EventArgs e) => { base.OnBackPressed(); }; viewdlg = SetViewDelegate; adapter = new GenericListAdapter<ItemStock> (this, listData, Resource.Layout.ItemStockDtls, viewdlg); listView.Adapter = adapter; listView.ItemClick+= ListView_Click; txtSearch.TextChanged+= TxtSearch_TextChanged; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); if (!((GlobalvarsApp)this.Application).ISLOGON) { Finish (); } SetTitle (Resource.String.submenu_summary); SetContentView (Resource.Layout.PrintInvSumm); pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH; apara = DataHelper.GetAdPara (pathToDatabase); Button butPrint= FindViewById<Button> (Resource.Id.printsumm); Button butInvBack= FindViewById<Button> (Resource.Id.printsumm_cancel); EditText frd = FindViewById<EditText> (Resource.Id.trxdatefr); EditText tod = FindViewById<EditText> (Resource.Id.trxdateto); imm = (InputMethodManager)GetSystemService(Context.InputMethodService); frd.Text = DateTime.Today.ToString ("dd-MM-yyyy"); frd.Click += delegate(object sender, EventArgs e) { imm.HideSoftInputFromWindow(frd.WindowToken, 0); ShowDialog (DATE_DIALOG_ID1); }; tod.Text = DateTime.Today.ToString ("dd-MM-yyyy"); date = DateTime.Today; tod.Click += delegate(object sender, EventArgs e) { imm.HideSoftInputFromWindow(tod.WindowToken, 0); ShowDialog (DATE_DIALOG_ID2); }; butInvBack.Click += (object sender, EventArgs e) => { StartActivity(typeof(TransListActivity)); }; butPrint.Click+= ButPrint_Click; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); RequestWindowFeature (WindowFeatures.NoTitle); SetContentView (Resource.Layout.home_layout); getScreenSize (); var btnSignIn = FindViewById<Button> (Resource.Id.btn_sigin_home); btnSignIn.Click += delegate { Intent intent = new Intent(this, typeof(LoginActivity)); StartActivity(intent); }; var btnRegister = FindViewById<Button> (Resource.Id.btn_registry_home); btnRegister.Click += (sender, e) => { utilsAndroid.onStartRegistry(this); }; inputManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService); edInputSearchName = FindViewById<EditText> (Resource.Id.edit_Search); var btnSearch = FindViewById<Button> (Resource.Id.btn_Search); btnSearch.Click += delegate{ searchEvent(); }; // Ask for use GPS if (!Utils.getAskedFirstTimeGPS ()) { InitializeLocationManager (); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); imm = (InputMethodManager)GetSystemService(Context.InputMethodService); var vowelsBtn = FindViewById<Button>(Resource.Id.vowels); var consonBtn = FindViewById<Button>(Resource.Id.consonants); var edittext = FindViewById<EditText>(Resource.Id.input); edittext.InputType = Android.Text.InputTypes.TextVariationPassword; edittext.KeyPress += (sender, e) => { imm.HideSoftInputFromWindow(edittext.WindowToken, HideSoftInputFlags.NotAlways); e.Handled = true; }; vowelsBtn.Click += (sender, e) => { int count = TextCounter.NumVowels(edittext.Text); string msg = count + " vowels found."; Toast.MakeText(this, msg, ToastLength.Short).Show(); }; consonBtn.Click += (sender, e) => { int count = TextCounter.NumConsonants(edittext.Text); string msg = count + " consonants found."; Toast.MakeText(this, msg, ToastLength.Short).Show(); }; }
public AndroidContext(Android.Content.Context context, InputMethodManager input, double width, double height) : base(context) { contentView = null; this.width = width; this.height = height; this.input = input; this.InputType = InputTypes.ClassText | InputTypes.TextVariationPassword; imageCache = new Dictionary<string, Bitmap>() { {"icon.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon) }, {"brøkbadge.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.brokbadge) }, {"master_of_algebrabadge.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.master_of_algebrabadge) }, {"parenthesis_badge.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.parenthesis_badge) }, {"star.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.star) }, {"star_activated.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.star_activated) }, {"tutorial_badge.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.tutorial_badge) }, {"restart.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.restart) }, {"potens_badge.png", BitmapFactory.DecodeResource(Resources, Resource.Drawable.potens_badge) } }; Text = ""; Append("webmat"); this.TextChanged += (obj, args) => { Console.WriteLine(this.Text); if (args.Text.ToString() == "webma") { contentView.KeyPressed("Back", this); Text = ""; Append("webmat"); } else if(args.Text.ToString().Length > "webmat".Length) { contentView.KeyPressed(args.Text.Last() + "", this); Text = ""; Append("webmat"); } }; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Create your application here SetContentView (Resource.Layout.active_code_layout); ActionBar.NavigationMode = ActionBarNavigationMode.Standard; ActionBar.Title = GetString(Resource.String.active_account_title); ActionBar.SetDisplayShowTitleEnabled (false); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowHomeEnabled (true); setHeadingTitle (GetString(Resource.String.active_account_title)); inputManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService); var edInputCode = FindViewById<EditText> (Resource.Id.ed_code_active); var btnSend = FindViewById<Button> (Resource.Id.btnSendActiveCode); var tvError = FindViewById<TextView> (Resource.Id.tvErrorActiveCode); tvError.Visibility = ViewStates.Gone; btnSend.Enabled = false; edInputCode.TextChanged += (sender, e) => { tvError.Visibility = ViewStates.Gone; if(edInputCode.Text.Count() <= 0) { btnSend.Enabled = false; } else { btnSend.Enabled = true; } }; btnSend.Click += (sender, e) => { inputManager.HideSoftInputFromWindow (edInputCode.WindowToken, 0); if(edInputCode.Text.Trim().Count() <= 0) { tvError.Visibility = ViewStates.Visible; } else { activeCodeRequest(edInputCode.Text.Trim()); } }; }
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Dialog.SetTitle (GetString (Resource.String.sign_in)); var v = inflater.Inflate (Resource.Layout.fingerprint_dialog_container, container, false); mCancelButton = (Button)v.FindViewById (Resource.Id.cancel_button); mCancelButton.Click += (object sender, EventArgs e) => Dismiss (); mSecondDialogButton = (Button)v.FindViewById (Resource.Id.second_dialog_button); mSecondDialogButton.Click += (object sender, EventArgs e) => { if (mStage == Stage.Fingerprint) { GoToBackup (); } else { VerifyPassword (); } }; mInputMethodManager = (InputMethodManager)Context.GetSystemService (Context.InputMethodService); mFingerprintContent = v.FindViewById (Resource.Id.fingerprint_container); mBackupContent = v.FindViewById (Resource.Id.backup_container); mPassword = v.FindViewById<EditText> (Resource.Id.password); mPassword.SetOnEditorActionListener (this); mPasswordDescriptionTextView = v.FindViewById<TextView> (Resource.Id.password_description); mUseFingerprintFutureCheckBox = v.FindViewById<CheckBox> (Resource.Id.use_fingerprint_in_future_check); mNewFingerprintEnrolledTextView = v.FindViewById<TextView> (Resource.Id.new_fingerprint_enrolled_description); var fingerprintManager = (FingerprintManager)Context.GetSystemService (Context.FingerprintService); mFingerprintUiHelperBuilder = new FingerprintUiHelper.FingerprintUiHelperBuilder (fingerprintManager); mFingerprintUiHelper = mFingerprintUiHelperBuilder.Build ( (ImageView)v.FindViewById (Resource.Id.fingerprint_icon), (TextView)v.FindViewById (Resource.Id.fingerprint_status), this); UpdateStage (); // If fingerprint authentication is not available, switch immediately to the backup // (password) screen. if (!mFingerprintUiHelper.IsFingerprintAuthAvailable) GoToBackup (); return v; }
private void ActivateEditTextImpl() { if(activeEditText != null) throw new Exception("Internal error: Can not activate edit text, another edit text is already active"); EnsureStaticEditText(); activeEditText = this; editText = staticEditText; // set up the initial state of the android EditText UpdateInputTypeImpl(); editText.SetMaxLines(MaxLines); editText.SetMinLines(MinLines); UpdateTextToEditImpl(); UpdateSelectionToEditImpl(); // add callbacks editText.EditorAction += AndroidEditTextOnEditorAction; editText.AfterTextChanged += AndroidEditTextOnAfterTextChanged; // add the edit to the overlay layout and show the layout GetGameContext().EditTextLayout.Visibility = ViewStates.Visible; // set the focus to the edit box editText.RequestFocus(); // activate the ime (show the keyboard) inputMethodManager = (InputMethodManager)PlatformAndroid.Context.GetSystemService(Context.InputMethodService); inputMethodManager.ShowSoftInput(staticEditText, ShowFlags.Forced); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // SetContentView(Resource.Layout.Main); // TxtUrl = FindViewById<EditText>(Resource.Id.txtUrl); _InputMethodManager = (InputMethodManager)GetSystemService(Context.InputMethodService); _InputMethodManager.HideSoftInputFromWindow( TxtUrl.WindowToken, HideSoftInputFlags.None); // var client = new ContentWebViewClient(); client.WebViewLocaitonChanged += (sender, e) => { WriteLine($"{ e.CommandString }"); }; // MyWebView = FindViewById<WebView>(Resource.Id.webview); MyWebView.SetWebViewClient(client); MyWebView.Settings.JavaScriptEnabled = true; // 負責與頁面溝通 - Native -> WebView JavaScriptResult callResult = new JavaScriptResult(); callResult.JavaScriptResultReceived += (object sender, JavaScriptResult.JavaScriptResultReceivedEventArgs e) => { WriteLine(e.Result); RunOnUiThread(() => { TxtUrl.Text = e.Result; }); }; // BtnGo = FindViewById<Button>(Resource.Id.btnGo); BtnGo.Click += (sender, e) => { RunOnUiThread(() => { MyWebView.EvaluateJavascript(@"msg( 1234 );", callResult); }); }; MyWebView.LoadDataWithBaseURL( null , @"<html> <head> <title>Local String</title> <style type='text/css'>p{font-family : Verdana; color : purple }</style> <script language='JavaScript'> var lookup = '中文訊息' function msg( text ){ return text + ' received'; } </script> </head> <body><p>Hello World!</p><br /> <button type='button' onclick='TP.CallFromPage(lookup)' text='Hi From Page'>Hi From Page</button> </body> </html>" , "text/html" , "utf-8" , null); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); _hoursPicker = FindViewById<NumberPicker>(Resource.Id.testHoursNumberPicker); _minutesPicker = FindViewById<NumberPicker>(Resource.Id.testMinutesNumberPicker); _hoursPicker.ValueChanged += (sender, args) => ValidateFieldsAndEnableButton(); _minutesPicker.ValueChanged += (sender, args) => ValidateFieldsAndEnableButton(); _hoursPicker.MaxValue = 12; _hoursPicker.MinValue = 0; _minutesPicker.MaxValue = 59; _minutesPicker.MinValue = 0; _inputManager = (InputMethodManager)GetSystemService(Context.InputMethodService); EditText hoursEditText = (EditText)_hoursPicker.GetChildAt(0); hoursEditText.Focusable = true; hoursEditText.FocusableInTouchMode = true; hoursEditText.FocusChange += HandleEditTextFocusChangedForKeyboard; //_inputManager.ShowSoftInput(hoursEditText, ShowFlags.Implicit); EditText minutesEditText = (EditText)_hoursPicker.GetChildAt(0); minutesEditText.Focusable = true; minutesEditText.FocusableInTouchMode = true; minutesEditText.FocusChange += HandleEditTextFocusChangedForKeyboard; //_inputManager.ShowSoftInput(minutesEditText, ShowFlags.Implicit); _totalQuestionsTextBox = FindViewById<EditText>(Resource.Id.totalQuestionsTextBox); _totalQuestionsTextBox.TextChanged += (sender, args) => ValidateFieldsAndEnableButton(); //_inputManager.ShowSoftInput(_totalQuestionsTextBox, ShowFlags.Implicit); _totalQuestionsTextBox.FocusChange += HandleEditTextFocusChangedForKeyboard; _startTimeButton = FindViewById<Button>(Resource.Id.startTimerButton); _startTimeButton.Click += delegate { int numberOfQuestions = !string.IsNullOrEmpty(_totalQuestionsTextBox.Text) ? Convert.ToInt32(_totalQuestionsTextBox.Text) : 0; if (_hoursPicker.Value == 0 && _minutesPicker.Value == 0 || numberOfQuestions == 0) { return; } var intent = new Intent(this, typeof(TimerViewActivity)); intent.PutExtra("hours", _hoursPicker.Value); intent.PutExtra("minutes", _minutesPicker.Value); intent.PutExtra("questions", numberOfQuestions); StartActivity(intent); }; ValidateFieldsAndEnableButton(); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.search_layout); searchActivity = this; if (!MApplication.getInstance ().isLogedIn) { ActionBar.NavigationMode = ActionBarNavigationMode.Standard; ActionBar.SetTitle (Resource.String.search_result_title); ActionBar.SetDisplayShowTitleEnabled (false); ActionBar.SetDisplayHomeAsUpEnabled (true); ActionBar.SetDisplayShowHomeEnabled (true); } else { searchActivity.menu = ((UserDashBoardMain)searchActivity.Parent).menu; if (searchActivity.menu != null) { searchActivity.menu.GetItem (0).SetEnabled (false); searchActivity.menu.GetItem (0).SetVisible(false); } } setHeadingTitle (Resource.String.search_title); tvSearchResult = FindViewById<TextView> (Resource.Id.tv_noresult_search); tvSearchLimit = FindViewById<TextView> (Resource.Id.tv_notice_limit_search); llProgress = FindViewById<LinearLayout> (Resource.Id.llProgressBar); specListView = FindViewById<ListView> (Resource.Id.search_list_result); searchView = FindViewById<SearchView> (Resource.Id.searchView); sortPopup = new SortPopup (this); sortPopup.sortDelegate = this; strKeyWordSeach = ""; resetData(); llProgress.Visibility = ViewStates.Visible; specListView.ItemClick += OnListItemClick; specListView.SetOnScrollListener(searchActivity); inputManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService); searchView.SetOnQueryTextListener (this); strSortType = Constants.SortBy.ProximityASC.ToString (); tvSearchResult.Visibility = ViewStates.Gone; if (this.Intent.Extras != null) { if (this.Intent.Extras.ContainsKey (constants.pKeyWordSearch) && constants.isSearchHome) { searchView.SetIconifiedByDefault (false); strKeyWordSeach = this.Intent.Extras.GetString (constants.pKeyWordSearch); searchView.SetQuery (strKeyWordSeach.Trim(), false); if (strKeyWordSeach.Trim ().Equals ("")) { tvSearchResult.Visibility = ViewStates.Visible; llProgress.Visibility = ViewStates.Gone; } else { getSpecialistProfilesRequest (); } constants.isSearchHome = false; } } else { searchView.SetIconifiedByDefault (false); searchView.RequestFocus (); llProgress.Visibility = ViewStates.Gone; } footerView = ((LayoutInflater)this.GetSystemService (Context.LayoutInflaterService)).Inflate (Resource.Layout.footer_loading_more, null, false); TCNotificationCenter.defaultCenter.addObserver (this, constants.kAddFavoriteSuccess, new TCSelector(updateSpecialistInfo)); TCNotificationCenter.defaultCenter.addObserver (this, constants.kRemoveFavoriteSuccess, new TCSelector (updateSpecialistInfo)); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); RequestWindowFeature (WindowFeatures.ActionBar); SetContentView (Resource.Layout.sign_in_layout); ActionBar.NavigationMode = ActionBarNavigationMode.Standard; ActionBar.SetTitle(Resource.String.signin_title); ActionBar.SetDisplayShowTitleEnabled (false); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetDisplayShowHomeEnabled (true); inputManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService); loginActivity = this; edUserName = FindViewById<EditText> (Resource.Id.edit_username_login); edPass = FindViewById<EditText> (Resource.Id.edit_pass_login); tvForgotPass = FindViewById<TextView> (Resource.Id.tv_forgotpass); tvRegister = FindViewById<TextView> (Resource.Id.tv_registry); cbRememberPass = FindViewById<CheckBox> (Resource.Id.checkbox_remember); cbShowPass = FindViewById<CheckBox>(Resource.Id.checkbox_showpassword); btnLogin = FindViewById<Button> (Resource.Id.btn_sigin); tvErrorLogin = FindViewById<TextView> (Resource.Id.tv_error_login); btnLogin.Enabled = false; btnLogin.Click += (sender, e) => { inputManager.HideSoftInputFromWindow (edUserName.WindowToken, 0); inputManager.HideSoftInputFromWindow (edPass.WindowToken, 0); sendLogin(); }; cbShowPass.CheckedChange+=(sender, e) => { Boolean isch =cbShowPass.Checked; if(cbShowPass.Checked){ edPass.TransformationMethod=global::Android.Text.Method.HideReturnsTransformationMethod.Instance; Utils.keepShowPassWord(true); }else{ edPass.TransformationMethod=global::Android.Text.Method.PasswordTransformationMethod.Instance; Utils.keepShowPassWord(false); } }; edUserName.TextChanged += (sender, e) => { tvErrorLogin.Visibility = ViewStates.Gone; if(edUserName.Text.Count() <= 0) { btnLogin.Enabled = false; } else { btnLogin.Enabled = true; } }; edPass.TextChanged += (sender, e) => { tvErrorLogin.Visibility = ViewStates.Gone; if(edPass.Text.Count() <= 0) { btnLogin.Enabled = false; } else { btnLogin.Enabled = true; } }; tvForgotPass.Click += (sender, e) => { Intent intent = new Intent(this, typeof(ResetPassword)); StartActivity(intent); }; tvRegister.Click += (sender, e) => { utilsAndroid.onStartRegistry(this); }; if (Utils.getRememberLogin ()) { if (Utils.getUserName () != null && Utils.getPassWord () != null) { edUserName.Text = Utils.getUserName (); edPass.Text = Utils.getPassWord (); cbRememberPass.Checked = true; } } if (Utils.getShowPassWord ()) { cbShowPass.Checked = true; edPass.TransformationMethod=global::Android.Text.Method.HideReturnsTransformationMethod.Instance; } else { cbShowPass.Checked = false; edPass.TransformationMethod=global::Android.Text.Method.PasswordTransformationMethod.Instance; } }
private void DeactivateEditTextImpl() { if (activeEditText == null) throw new Exception("Internal error: Can not deactivate the EditText, it is already nullified"); // remove callbacks editText.EditorAction -= AndroidEditTextOnEditorAction; editText.AfterTextChanged -= AndroidEditTextOnAfterTextChanged; editText.ClearFocus(); editText = null; activeEditText = null; // remove the edit text from the layout and hide the layout GetGameContext().EditTextLayout.Visibility = ViewStates.Gone; // deactivate the ime (hide the keyboard) if (staticEditText != null) // staticEditText can be null if window have already been detached. inputMethodManager.HideSoftInputFromWindow(staticEditText.WindowToken, HideSoftInputFlags.None); inputMethodManager = null; FocusedElement = null; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.SessionView); _textToSend = FindViewById<EditText> (Resource.Id.textViewUpload); _tvShareCount = FindViewById<TextView> (Resource.Id.tvShareCount); _tvCodeWord = FindViewById<TextView> (Resource.Id.tvCodeWord); _chooseContent = FindViewById<Button> (Resource.Id.btnChooseContent); _mainLayout = FindViewById<LinearLayout> (Resource.Id.shareLayout); var btnSend = FindViewById<Button> (Resource.Id.buttonSend); btnSend.Click += (object sender, EventArgs e) => { SendText (); }; _textToSend.KeyPress += (object sender, View.KeyEventArgs e) => { if (e.KeyCode == Keycode.Enter && e.Event.Action == KeyEventActions.Down) { SendText (); } else e.Handled = false; }; _chooseContent.Click += ChooseFile; var phrase = Intent.GetStringExtra ("Secret"); _secret = CrossCopyApp.HistoryData.Secrets.Where (s => s.Phrase == phrase).SingleOrDefault (); if (_secret == null) Finish (); _secret.WatchEvent += UpdateSharedDevicesCount; CrossCopyApp.Srv.CurrentSecret = _secret; GetString (Resource.String.SessionTitle); _tvCodeWord.Text = _secret.Phrase; _tvShareCount.Text = GetString (Resource.String.ShareWithNoDevices); _inflater = (LayoutInflater)GetSystemService (Context.LayoutInflaterService); _inputMethodManager = (InputMethodManager)GetSystemService (InputMethodService); HandlePossibleSharedContent (); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); // SetContentView (Resource.Layout.Main); var client = new ContentWebViewClient (); client.WebViewLocaitonChanged += (object sender, ContentWebViewClient.WebViewLocaitonChangedEventArgs e) => { WriteLine (e.CommandString); }; client.WebViewLoadCompleted += (object sender, ContentWebViewClient.WebViewLoadCompletedEventArgs e) => { RunOnUiThread (() => { AndHUD.Shared.Dismiss (this); }); }; MyWebView = FindViewById<WebView> (Resource.Id.webview); MyWebView.SetWebViewClient (client); MyWebView.Settings.JavaScriptEnabled = true; MyWebView.Settings.UserAgentString = @"Android"; #region EditText _InputMethodManager = (InputMethodManager)GetSystemService (Context.InputMethodService); TxtUrl = FindViewById<EditText> (Resource.Id.txtUrl); TxtUrl.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => { WriteLine (TxtUrl.Text + ":" + e.Text); }; #endregion BtnGo = FindViewById<Button> (Resource.Id.btnGo); BtnGo.Click += (object sender, EventArgs e) => { // 隱藏鍵盤 _InputMethodManager.HideSoftInputFromWindow ( TxtUrl.WindowToken, HideSoftInputFlags.None); // var url = TxtUrl.Text.Trim (); // 詢問是否要過去指定頁面 AlertDialog.Builder alert = new AlertDialog.Builder (this); alert.SetTitle ("Info"); alert.SetMessage ( $"請問是否前往 { url }" ); alert.SetNegativeButton ("取消", (senderAlert, args) => { }); alert.SetPositiveButton ("確認", (senderAlert, args) => { RunOnUiThread ( () => { AndHUD.Shared.Show (this, "Status Message", -1, MaskType.Clear); } ); MyWebView.LoadUrl (url); }); RunOnUiThread (() => { alert.Show (); }); }; }