本文整理汇总了C#中EditText.ClearFocus方法的典型用法代码示例。如果您正苦于以下问题:C# EditText.ClearFocus方法的具体用法?C# EditText.ClearFocus怎么用?C# EditText.ClearFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditText
的用法示例。
在下文中一共展示了EditText.ClearFocus方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated
public void Binding_TwoWayFromViewModelToEditTextWithObserveEvent_BindingGetsUpdated()
{
var vm = new TestViewModel
{
Model = new TestModel()
};
var control1 = new EditText(Application.Context);
var binding = new Binding<string, string>(
vm,
() => vm.Model.MyProperty,
control1,
() => control1.Text,
BindingMode.TwoWay)
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
Assert.AreEqual(null, vm.Model.MyProperty);
Assert.AreEqual(string.Empty, control1.Text);
var value = DateTime.Now.Ticks.ToString();
vm.Model.MyProperty = value;
Assert.AreEqual(value, vm.Model.MyProperty);
Assert.AreEqual(vm.Model.MyProperty, control1.Text);
var newValue = value + "Suffix";
control1.RequestFocus();
control1.Text = newValue;
Assert.AreEqual(newValue, control1.Text);
Assert.AreEqual(value, vm.Model.MyProperty);
control1.ClearFocus();
Assert.AreEqual(newValue, vm.Model.MyProperty);
}
示例2: Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated
public void Binding_OneWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
{
var control1 = new EditText(Application.Context);
var control2 = new CheckBox(Application.Context);
var binding = new Binding<string, bool>(
control1,
() => control1.Text,
control2,
() => control2.Checked)
.ObserveSourceEvent(UpdateTriggerMode.LostFocus);
Assert.AreEqual(string.Empty, control1.Text);
Assert.IsFalse(control2.Checked);
var value = "True";
control1.RequestFocus();
control1.Text = value;
Assert.AreEqual(value, control1.Text);
Assert.IsFalse(control2.Checked);
control1.ClearFocus();
Assert.IsTrue(control2.Checked);
}
示例3: Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated
public void Binding_TwoWayFromEditTextToCheckBoxWithObserveEvent_BindingGetsUpdated()
{
var control1 = new EditText(Application.Context);
var control2 = new CheckBox(Application.Context);
var binding = new Binding<string, bool>(
control1,
() => control1.Text,
control2,
() => control2.Checked,
BindingMode.TwoWay)
.ObserveSourceEvent(UpdateTriggerMode.LostFocus)
.ObserveTargetEvent(); // LostFocus doesn't work programatically with CheckBoxes
Assert.AreEqual(string.Empty, control1.Text);
Assert.IsFalse(control2.Checked);
var value = "True";
control1.RequestFocus();
control1.Text = value;
Assert.AreEqual(value, control1.Text);
Assert.IsFalse(control2.Checked);
control1.ClearFocus();
Assert.IsTrue(control2.Checked);
control2.Checked = false;
Assert.IsFalse(control2.Checked);
Assert.AreEqual("False", control1.Text);
}
示例4: Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated
public void Binding_TwoWayFromEditTextToEditTextWithObserveEvent_BindingGetsUpdated()
{
var control1 = new EditText(Application.Context);
var control2 = new EditText(Application.Context);
var binding = new Binding<string, string>(
control1,
() => control1.Text,
control2,
() => control2.Text,
BindingMode.TwoWay)
.ObserveSourceEvent(UpdateTriggerMode.LostFocus)
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
Assert.AreEqual(string.Empty, control1.Text);
Assert.AreEqual(string.Empty, control2.Text);
var value = DateTime.Now.Ticks.ToString();
control1.RequestFocus();
control1.Text = value;
Assert.AreEqual(value, control1.Text);
Assert.AreEqual(string.Empty, control2.Text);
control1.ClearFocus();
Assert.AreEqual(control1.Text, control2.Text);
var newValue = value + "Suffix";
control2.RequestFocus();
control2.Text = newValue;
Assert.AreEqual(newValue, control2.Text);
Assert.AreEqual(value, control1.Text);
control2.ClearFocus();
Assert.AreEqual(control2.Text, control1.Text);
}
示例5: Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated
public void Binding_TwoWayFromCheckBoxToEditTextWithUpdateTrigger_BindingGetsUpdated()
{
var control1 = new EditText(Application.Context);
var control2 = new CheckBox(Application.Context);
_binding = new Binding<bool, string>(
control2,
() => control2.Checked,
control1,
() => control1.Text,
BindingMode.TwoWay)
.UpdateSourceTrigger() // LostFocus doesn't work programatically with CheckBoxes
.ObserveTargetEvent(UpdateTriggerMode.LostFocus);
Assert.AreEqual("False", control1.Text);
Assert.IsFalse(control2.Checked);
control2.Checked = true;
Assert.IsTrue(control2.Checked);
Assert.AreEqual("True", control1.Text);
var value = "False";
control1.RequestFocus();
control1.Text = value;
Assert.AreEqual(value, control1.Text);
Assert.IsTrue(control2.Checked);
control1.ClearFocus();
Assert.IsFalse(control2.Checked);
}
示例6: Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated
public void Binding_OneWayFromEditTextToViewModelWithObserveEvent_BindingGetsUpdated()
{
var vm = new TestViewModel
{
Model = new TestModel()
};
var control1 = new EditText(Application.Context);
var binding = new Binding<string, string>(
control1,
() => control1.Text,
vm,
() => vm.Model.MyProperty)
.ObserveSourceEvent(UpdateTriggerMode.LostFocus);
Assert.AreEqual(string.Empty, control1.Text);
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
var value = DateTime.Now.Ticks.ToString();
control1.RequestFocus();
control1.Text = value;
Assert.AreEqual(value, control1.Text);
Assert.AreEqual(string.Empty, vm.Model.MyProperty);
control1.ClearFocus();
Assert.AreEqual(control1.Text, vm.Model.MyProperty);
}
示例7: Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated
public void Binding_OneWayFromEditTextToEditTextWithUpdateTrigger_BindingGetsUpdated()
{
var control1 = new EditText(Application.Context);
var control2 = new EditText(Application.Context);
_binding = new Binding<string, string>(
control1,
() => control1.Text,
control2,
() => control2.Text)
.UpdateSourceTrigger(UpdateTriggerMode.LostFocus);
Assert.AreEqual(string.Empty, control1.Text);
Assert.AreEqual(string.Empty, control2.Text);
var value = DateTime.Now.Ticks.ToString();
control1.RequestFocus();
control1.Text = value;
Assert.AreEqual(value, control1.Text);
Assert.AreEqual(string.Empty, control2.Text);
control1.ClearFocus();
Assert.AreEqual(control1.Text, control2.Text);
}
示例8: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
view = inflater.Inflate(Resource.Layout.work_path_fragment, container, false);
workPathLayout = view.FindViewById<LinearLayout>(Resource.Id.work_path_layout);
coordinatorLayout = view.FindViewById<CoordinatorLayout>(Resource.Id.coordinator_layout);
string workPath = Pref.WorkPath;
workPathFragment = (FileListFragment)ChildFragmentManager.FindFragmentById(Resource.Id.work_path_fragment);
workPathFragment.RefreshFilesList(workPath);
workPathFragment.SnackbarView = coordinatorLayout;
//workPathFragment.PrefKey = Pref.WorkPathKey;
etWorkPath = view.FindViewById<EditText>(Resource.Id.etWorkPath);
etWorkPath.Text = workPath;
etWorkPath.FocusChange += (object sender, View.FocusChangeEventArgs e) =>
{
try {
var dir = new DirectoryInfo(etWorkPath.Text);
if (dir.IsDirectory()) {
Pref.WorkPath = etWorkPath.Text;
} else {
Show("잘못된 경로: " + etWorkPath.Text);
etWorkPath.Text = Pref.WorkPath;
}
} catch {
Show("잘못된 경로: " + etWorkPath.Text);
etWorkPath.Text = Pref.WorkPath;
}
workPathFragment.RefreshFilesList(etWorkPath.Text);
};
etWorkPath.KeyPress += (object sender, View.KeyEventArgs e) =>
{
e.Handled = false;
if (e.KeyCode == Keycode.Enter || e.KeyCode == Keycode.Back || e.KeyCode == Keycode.Escape) {
var imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(etWorkPath.WindowToken, 0);
etWorkPath.ClearFocus();
e.Handled = true;
}
};
workPathToolbar = view.FindViewById<Toolbar>(Resource.Id.work_path_toolbar);
workPathToolbar.InflateMenu(Resource.Menu.toolbar_work_path_menu);
workPathToolbar.MenuItemClick += (sender, e) =>
{
//Toast.MakeText(this, "Bottom toolbar pressed: " + e.Item.TitleFormatted, ToastLength.Short).Show();
bool ret;
switch (e.Item.ItemId) {
case Resource.Id.toolbar_work_path_menu_up:
OnBackPressedFragment();
break;
case Resource.Id.toolbar_work_path_menu_home:
if (!Refresh(Pref.WorkPath))
Show("경로 이동 실패: " + Pref.WorkPath);
break;
case Resource.Id.toolbar_work_path_menu_storage:
if (!Refresh("/storage"))
Show("경로 이동 실패: " + "/storage");
break;
case Resource.Id.toolbar_work_path_menu_sdcard:
if (!Refresh(Environment.ExternalStorageDirectory.AbsolutePath))
Show("경로 이동 실패: " + Environment.ExternalStorageDirectory.AbsolutePath);
break;
case Resource.Id.toolbar_work_path_menu_extsdcard:
ret = false;
try {
var dir = new DirectoryInfo("/storage");
foreach (var item in dir.GetDirectories()) {
if (item.Name.ToLower().StartsWith("ext") || item.Name.ToLower().StartsWith("sdcard1")) {
foreach (var subItem in item.GetFileSystemInfos()) {
if (Refresh(item.FullName)) {
ret = true;
break;
}
}
}
}
} catch { }
if (!ret)
Show("경로 이동 실패: " + "SD 카드");
break;
case Resource.Id.toolbar_work_path_menu_usbstorage:
ret = false;
try {
var dir = new DirectoryInfo("/storage");
foreach (var item in dir.GetDirectories()) {
if (item.Name.ToLower().StartsWith("usb")) {
foreach (var subItem in item.GetFileSystemInfos()) {
if (Refresh(item.FullName)) {
ret = true;
break;
}
}
}
}
} catch { }
if (!ret)
Show("경로 이동 실패: " + "USB 저장소");
break;
}
//.........这里部分代码省略.........
示例9: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
view = inflater.Inflate(Resource.Layout.backup_path_fragment, container, false);
backupPathLayout = view.FindViewById<LinearLayout>(Resource.Id.backup_path_layout);
coordinatorLayout = view.FindViewById<CoordinatorLayout>(Resource.Id.coordinator_layout);
string backupPath = Pref.BackupPath;
backupPathFragment = (FileListFragment)ChildFragmentManager.FindFragmentById(Resource.Id.backup_path_fragment);
backupPathFragment.RefreshFilesList(backupPath);
backupPathFragment.SnackbarView = coordinatorLayout;
//backupPathFragment.PrefKey = Pref.BackupPathKey;
etBackupPath = view.FindViewById<EditText>(Resource.Id.etBackupPath);
etBackupPath.Text = backupPath;
etBackupPath.FocusChange += (object sender, View.FocusChangeEventArgs e) =>
{
try {
var dir = new DirectoryInfo(etBackupPath.Text);
if (dir.IsDirectory()) {
Pref.BackupPath = etBackupPath.Text;
} else {
Show("잘못된 경로: " + etBackupPath.Text);
etBackupPath.Text = Pref.BackupPath;
}
} catch {
Show("잘못된 경로: " + etBackupPath.Text);
etBackupPath.Text = Pref.BackupPath;
}
backupPathFragment.RefreshFilesList(etBackupPath.Text);
};
etBackupPath.KeyPress += (object sender, View.KeyEventArgs e) =>
{
e.Handled = false;
if (e.KeyCode == Keycode.Enter || e.KeyCode == Keycode.Back || e.KeyCode == Keycode.Escape) {
var imm = (InputMethodManager)Context.GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(etBackupPath.WindowToken, 0);
etBackupPath.ClearFocus();
e.Handled = true;
}
};
backupPathToolbar = view.FindViewById<Toolbar>(Resource.Id.backup_path_toolbar);
backupPathToolbar.InflateMenu(Resource.Menu.toolbar_backup_path_menu);
backupPathToolbar.MenuItemClick += (sender, e) =>
{
switch (e.Item.ItemId) {
case Resource.Id.toolbar_backup_path_menu_up:
OnBackPressedFragment();
break;
case Resource.Id.toolbar_backup_path_menu_home:
Refresh(Pref.BackupPath);
break;
case Resource.Id.toolbar_backup_path_menu_restore:
Show(Restore());
break;
}
};
fab = view.FindViewById<FloatingActionButton>(Resource.Id.fab);
fab.Click += (sender, e) =>
{
Show(Backup());
};
return view;
}
示例10: OnCreate
// async void example(){
// ParseObject gameScore = new ParseObject("GameScore");
// gameScore["score"] = 1337;
// gameScore["playerName"] = "Sean Plott";
// await gameScore.SaveAsync();
// }
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// ParseClient.Initialize("LNAuxom26NKczyL2hfU3deDyFvxkR9vAEVt3NYom",
// "pTK01DCWyIlw3DQJludWbtnBgvpe2PqNFKa8aDmm");
//example ();
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
string Dominio_webservice = "http://alertapp-jovel.rhcloud.com/index.php/Mobile";
WebServices = new Dictionary<string, System.Uri> {
{"getDenuncias",new System.Uri(Dominio_webservice+"/getDenuncias")},
{"setDenuncia",new System.Uri(Dominio_webservice+"/setDenuncia")},
{"getDenunciaPicture",new System.Uri(Dominio_webservice+"/getDenunciaPicture")}
};
//este diccionario dejo de usarse pero puede resultar util luego
ColorTipoDenuncia = new Dictionary<int, float>{
{1, BitmapDescriptorFactory.HueRed},
{2, BitmapDescriptorFactory.HueAzure},
{3, BitmapDescriptorFactory.HueGreen},
{4, BitmapDescriptorFactory.HueYellow},
};
MarkerTipoDenuncia = new Dictionary<int, int>{
{1, Resource.Drawable.corte_marker},
{2, Resource.Drawable.fuga_marker},
{3, Resource.Drawable.damage_marker},
{4, Resource.Drawable.otros_marker}
};
btnNormal = FindViewById<Button>(Resource.Id.btnNormal);
btnSatellite = FindViewById<Button>(Resource.Id.btnSatellite);
ibtnReload = FindViewById<ImageButton>(Resource.Id.ibtnReload);
ibtnGps = FindViewById<ImageButton>(Resource.Id.ibtnGps);
ibtnSearch = FindViewById<ImageButton>(Resource.Id.ibtnSearch);
txtBuscar = FindViewById<EditText>(Resource.Id.txtBuscar);
txtBuscar.ClearFocus();
btnNormal.RequestFocus();
btnNormal.Click +=btnNormal_Click;
btnSatellite.Click +=btnSatellite_Click;
txtBuscar.EditorAction += txtBuscar_EditorAction;
ibtnReload.Click += ibtnReload_Click;
ibtnGps.Click += ibtnGps_Click;
ibtnSearch.Click += ibtnSearch_Click;
toolBar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
toolBar.SetTitleTextColor(Color.White);
mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawe_layout);
mLeftDrawer = FindViewById<ListView>(Resource.Id.left_drawer);
SetSupportActionBar(toolBar);
mLeftDataSet = new List<string>();
mLeftDataSet.Add("Bienvenido Luis Jovel");
mLeftDataSet.Add("Listado de Denuncias");
mLeftDataSet.Add("Filtrar Resultados");
mLeftDataSet.Add(" Ver Todos");
mLeftDataSet.Add(" Corte de servicio");
mLeftDataSet.Add(" Fuga de Agua");
mLeftDataSet.Add(" Daño a Infraestructura");
mLeftDataSet.Add(" Otros");
mLeftDataSet.Add("Cerrar Sesion");
mLeftAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
mLeftDrawer.ItemClick += mLeftDrawer_ItemClick;
mLeftDrawer.Adapter = mLeftAdapter;
mDrawerToggle = new MyActionBarDrawerToggle(
this,
mDrawerLayout,
Resource.String.openDrawer,
Resource.String.closeDrawer
);
mDrawerLayout.SetDrawerListener(mDrawerToggle);
SupportActionBar.SetHomeButtonEnabled(true);
SupportActionBar.SetDisplayShowTitleEnabled(true);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
mDrawerToggle.SyncState();
//GPS NUEVO
setupGPS();
SetUpMap();
//GPS OBSOLETO
// InitializeLocationManager();
cliente = new WebClient();
//llamar a web service
cliente.DownloadDataAsync(WebServices["getDenuncias"]);
cliente.DownloadDataCompleted += cliente_DownloadDataCompleted;
//alertdialog
builder = new Android.App.AlertDialog.Builder(this);
alert = builder.Create();
}
示例11: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
base.OnCreateView (inflater, container, savedInstanceState);
var view = inflater.Inflate (Resource.Layout.LogInDialog, container, false);
mTxtUserName = view.FindViewById<EditText> (Resource.Id.txtUserName);
mTxtPassword = view.FindViewById<EditText> (Resource.Id.txtPassword);
mCheckbox = view.FindViewById<CheckBox> (Resource.Id.LoginCheckBox);
try{
var CheckPrefs = Application.Context.GetSharedPreferences("MyCheckState", FileCreationMode.Private);
checkState = CheckPrefs.GetString("CheckState", null);
}catch{
}
switch (checkState)
{
case "False":
mCheckbox.Checked = false;
break;
case "True":
mCheckbox.Checked = true;
try{
var UsernamePrefs = Application.Context.GetSharedPreferences("username", FileCreationMode.Private);
mTxtUserName.Text = UsernamePrefs.GetString("username", null);
}catch{
}
try{
var PasswordPrefs = Application.Context.GetSharedPreferences("password", FileCreationMode.Private);
mTxtPassword.Text = PasswordPrefs.GetString("password", null);
}catch{
}
break;
default:
mCheckbox.Checked = true;
break;
}
mBtnSignUp = view.FindViewById<Button> (Resource.Id.btnLogInDialog);
mErrorText = view.FindViewById<TextView> (Resource.Id.txtError);
mProgressBar = view.FindViewById<ProgressBar> (Resource.Id.progressBar);
mProgressBar.Visibility = ViewStates.Invisible;
mBtnSignUp.Click += (object sender, EventArgs e) => {
mProgressBar.Visibility = ViewStates.Visible;
mTxtUserName.ClearFocus();
mErrorText.ClearFocus();
mBtnSignUp.RequestFocus();
mErrorText.Text=string.Format("登录中...");
//关键盘
InputMethodManager inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService);
inputManager.HideSoftInputFromWindow(mTxtPassword.WindowToken, HideSoftInputFlags.None);
inputManager.HideSoftInputFromWindow(mTxtUserName.WindowToken, HideSoftInputFlags.None);
mWorker=new BackgroundWorker();
mWorker.WorkerSupportsCancellation = true;
mWorker.DoWork+= delegate(object sender1, DoWorkEventArgs e1) {
BackgroundWorker mworker = sender1 as BackgroundWorker;
if (mworker.CancellationPending == true) {
e1.Cancel = true;
} else {
checkPassword();
}
};
mWorker.RunWorkerCompleted+=delegate(object sender1, RunWorkerCompletedEventArgs e1) {
if (e1.Cancelled == true) {
} else if (!(e1.Error == null)) {
} else {
worker_RunWorkerCompleted();
}
};
if (mWorker.IsBusy != true) {
mWorker.RunWorkerAsync ();
}
//.........这里部分代码省略.........