本文整理汇总了C#中EditText.SetSelection方法的典型用法代码示例。如果您正苦于以下问题:C# EditText.SetSelection方法的具体用法?C# EditText.SetSelection怎么用?C# EditText.SetSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditText
的用法示例。
在下文中一共展示了EditText.SetSelection方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
/// <summary>
/// Called when [create].
/// </summary>
/// <param name="bundle">The bundle.</param>
protected override void OnCreate(Bundle bundle)
{
try
{
base.OnCreate(bundle);
this.RequestWindowFeature(WindowFeatures.NoTitle);
SetContentView(Resource.Layout.Login);
var loginButton = FindViewById<Button>(Resource.Id.btnLogin);
loginButton.Click += loginButton_Click;
txtUserName = FindViewById<EditText>(Resource.Id.txtUserName);
txtPassword = FindViewById<EditText>(Resource.Id.txtPassword);
chkRememberMe = FindViewById<CheckBox>(Resource.Id.chkRememberMe);
ResetControl();
txtUserName.Text = DecurtisDomain;
txtUserName.SetSelection(txtUserName.Text.Length);
if (ApplicationData.User != null && !string.IsNullOrEmpty(ApplicationData.User.LoginName))
{
txtUserName.Text = ApplicationData.User.LoginName;
}
}
catch (Exception e)
{
AlertMessage(GetString(Resource.String.Error), e.Message.ToString());
}
// Create your application here
}
示例2: PlatformShow
private static Task<string> PlatformShow(string title, string description, string defaultText, bool usePasswordMode)
{
tcs = new TaskCompletionSource<string>();
Game.Activity.RunOnUiThread(() =>
{
alert = new AlertDialog.Builder(Game.Activity).Create();
alert.SetTitle(title);
alert.SetMessage(description);
var input = new EditText(Game.Activity) { Text = defaultText };
if (defaultText != null)
input.SetSelection(defaultText.Length);
if (usePasswordMode)
input.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
alert.SetView(input);
alert.SetButton((int)DialogButtonType.Positive, "Ok", (sender, args) =>
{
if (!tcs.Task.IsCompleted)
tcs.SetResult(input.Text);
});
alert.SetButton((int)DialogButtonType.Negative, "Cancel", (sender, args) =>
{
if (!tcs.Task.IsCompleted)
tcs.SetResult(null);
});
alert.CancelEvent += (sender, args) =>
{
if (!tcs.Task.IsCompleted)
tcs.SetResult(null);
};
alert.Show();
});
return tcs.Task;
}
示例3: ShowKeyboardInput
//android:inputType="none"--������ͨ�ַ�
//android:inputType="text"--������ͨ�ַ�
//android:inputType="textCapCharacters"--������ͨ�ַ�
//android:inputType="textCapWords"--��������ĸ��С
//android:inputType="textCapSentences"--����һ����ĸ��С
//android:inputType="textAutoCorrect"--ǰ�����Զ����
//android:inputType="textAutoComplete"--ǰ�����Զ����
//android:inputType="textMultiLine"--��������
//android:inputType="textImeMultiLine"--���뷨���У���һ��֧�֣�
//android:inputType="textNoSuggestions"--����ʾ
//android:inputType="textUri"--URI��ʽ
//android:inputType="textEmailAddress"--�����ʼ���ַ��ʽ
//android:inputType="textEmailSubject"--�ʼ������ʽ
//android:inputType="textShortMessage"--����Ϣ��ʽ
//android:inputType="textLongMessage"--����Ϣ��ʽ
//android:inputType="textPersonName"--������ʽ
//android:inputType="textPostalAddress"--������ʽ
//android:inputType="textPassword"--�����ʽ
//android:inputType="textVisiblePassword"--����ɼ���ʽ
//android:inputType="textWebEditText"--��Ϊ��ҳ������ı���ʽ
//android:inputType="textFilter"--�ı�ɸѡ��ʽ
//android:inputType="textPhonetic"--ƴ�������ʽ
//android:inputType="number"--���ָ�ʽ
//android:inputType="numberSigned"--�з������ָ�ʽ
//android:inputType="numberDecimal"--���Դ�С����ĸ����ʽ
//android:inputType="phone"--���ż���
//android:inputType="datetime"
//android:inputType="date"--���ڼ���
//android:inputType="time"--ʱ�����
public static void ShowKeyboardInput(string title, string description, string defaultText, Action<string> callback, string inputType = "")
{
Game.Activity.RunOnUiThread(() =>
{
var alert = new AlertDialog.Builder(Game.Activity);
alert.SetTitle(title);
alert.SetMessage(description);
var input = new EditText(Game.Activity) { Text = defaultText };
if (defaultText != null)
{
input.SetSelection(defaultText.Length);
}
if (inputType == "textPassword")
{
input.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
}
else if(inputType == "number")
{
input.InputType = Android.Text.InputTypes.ClassNumber;
}
alert.SetView(input);
alert.SetPositiveButton("Ok", (dialog, whichButton) =>
{
if (callback != null)
callback(input.Text);
});
alert.SetNegativeButton("Cancel", (dialog, whichButton) =>
{
if (callback != null)
callback(null);
});
alert.SetCancelable(false);
alert.Show();
});
}
示例4: showGetRoomUI
private void showGetRoomUI()
{
EditText roomInput = new EditText(this);
roomInput.Text = "https://apprtc.appspot.com/?r=";
roomInput.SetSelection(roomInput.Text.Length);
IDialogInterfaceOnClickListener listener = new OnClickListenerAnonymousInnerClassHelper(this, roomInput);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetMessage("Enter room URL").SetView(roomInput).SetPositiveButton("Go!", listener).Show();
}
示例5: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
var view = inflater.Inflate(Resource.Layout.inputdialogbox,container, false);
mSavebtn = view.FindViewById<Button>(Resource.Id.savebudget);
mBudgetInput = view.FindViewById<EditText>(Resource.Id.budgetvalue);
mBudgetInput.Text = m_existingbudget.ToString();
mBudgetInput.SetSelection(mBudgetInput.Text.Length);
mSavebtn.Click += onSaveButtonClicked;
return view;
}
示例6: ShowKeyboardInput
public static string ShowKeyboardInput(
PlayerIndex player,
string title,
string description,
string defaultText,
bool usePasswordMode)
{
string result = null;
EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
IsVisible = true;
Game.Activity.RunOnUiThread(() =>
{
var alert = new AlertDialog.Builder(Game.Activity);
alert.SetTitle(title);
alert.SetMessage(description);
var input = new EditText(Game.Activity) { Text = defaultText };
if (defaultText != null)
{
input.SetSelection(defaultText.Length);
}
if (usePasswordMode)
{
input.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
}
alert.SetView(input);
alert.SetPositiveButton("Ok", (dialog, whichButton) =>
{
result = input.Text;
IsVisible = false;
waitHandle.Set();
});
alert.SetNegativeButton("Cancel", (dialog, whichButton) =>
{
result = null;
IsVisible = false;
waitHandle.Set();
});
alert.SetCancelable(false);
alert.Show();
});
waitHandle.WaitOne();
IsVisible = false;
return result;
}
示例7: ShowKeyboardInput
public static string ShowKeyboardInput(
PlayerIndex player,
string title,
string description,
string defaultText,
bool usePasswordMode)
{
string result = defaultText;
if (!isKeyboardInputShowing)
{
isKeyboardInputShowing = true;
}
isVisible = isKeyboardInputShowing;
Game.Activity.RunOnUiThread(() =>
{
var alert = new AlertDialog.Builder(Game.Activity);
alert.SetTitle(title);
alert.SetMessage(description);
var input = new EditText(Game.Activity) { Text = defaultText };
if (defaultText != null)
{
input.SetSelection(defaultText.Length);
}
if (usePasswordMode)
{
input.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;
}
alert.SetView(input);
alert.SetPositiveButton("Ok", (dialog, whichButton) =>
{
result = input.Text;
isVisible = false;
});
alert.SetNegativeButton("Cancel", (dialog, whichButton) =>
{
result = null;
isVisible = false;
});
alert.Show();
});
while (isVisible)
{
Thread.Sleep(1);
}
return result;
}
示例8: ShowKeyboardInput
public string ShowKeyboardInput(
string defaultText)
{
var waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
OnKeyboardWillShow();
IsVisible = true;
CCGame.Activity.RunOnUiThread(() =>
{
var alert = new AlertDialog.Builder(Game.Activity);
var input = new EditText(Game.Activity) { Text = defaultText };
// Set the input fields input filter to accept only uppercase
input.SetFilters ( new Android.Text.IInputFilter[] { new Android.Text.InputFilterAllCaps() });
if (defaultText != null)
{
input.SetSelection(defaultText.Length);
}
alert.SetView(input);
alert.SetPositiveButton("Ok", (dialog, whichButton) =>
{
ContentText = input.Text;
waitHandle.Set();
IsVisible = false;
OnKeyboardWillHide();
});
alert.SetNegativeButton("Cancel", (dialog, whichButton) =>
{
ContentText = null;
waitHandle.Set();
IsVisible = false;
OnKeyboardWillHide();
});
alert.SetCancelable(false);
alertDialog = alert.Create();
alertDialog.Show();
OnKeyboardDidShow();
});
waitHandle.WaitOne();
if (alertDialog != null)
{
alertDialog.Dismiss();
alertDialog.Dispose();
alertDialog = null;
}
OnReplaceText(new CCIMEKeybardEventArgs(contentText, contentText.Length));
IsVisible = false;
return contentText;
}
示例9: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
inputOutput = FindViewById<EditText>(Resource.Id.InputOut);
// Get our button from the layout resource,
// and attach an event to it
//Button button = FindViewById<Button>(Resource.Id.MyButton);
//button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
FindViewById<Button>(Resource.Id.buttonOne).Click += (sender,e) =>
{
inputOutput.Text += "1";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonTwo).Click += (sender, e) =>
{
inputOutput.Text += "2";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonThree).Click += (sender, e) =>
{
inputOutput.Text += "3";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonFour).Click += (sender, e) =>
{
inputOutput.Text += "4";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonFive).Click += (sender, e) =>
{
inputOutput.Text += "5";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonSix).Click += (sender, e) =>
{
inputOutput.Text += "6";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonSeven).Click += (sender, e) =>
{
inputOutput.Text += "7";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonEight).Click += (sender, e) =>
{
inputOutput.Text += "8";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonNine).Click += (sender, e) =>
{
inputOutput.Text += "9";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonZero).Click += (sender, e) =>
{
inputOutput.Text += "0";
inputOutput.SetSelection(inputOutput.Text.Length);
};
FindViewById<Button>(Resource.Id.buttonCE).Click += (sender, e) =>
{
inputOutput.Text = string.Empty;
firstNumber = 0;
operation = Operation.Non;
};
FindViewById<Button>(Resource.Id.buttonPlus).Click += (sender, e) =>
{
firstNumber =Convert.ToDecimal(inputOutput.Text);
operation=Operation.Plus;
inputOutput.Text=string.Empty;
};
FindViewById<Button>(Resource.Id.buttonMinus).Click += (sender, e) =>
{
firstNumber = Convert.ToDecimal(inputOutput.Text);
operation = Operation.Subtract;
inputOutput.Text = string.Empty;
};
FindViewById<Button>(Resource.Id.buttonMulti).Click += (sender, e) =>
{
firstNumber = Convert.ToDecimal(inputOutput.Text);
operation = Operation.Multiply;
inputOutput.Text = string.Empty;
};
FindViewById<Button>(Resource.Id.buttonDivide).Click += (sender, e) =>
{
firstNumber = Convert.ToDecimal(inputOutput.Text);
operation = Operation.Divide;
inputOutput.Text = string.Empty;
};
FindViewById<Button>(Resource.Id.buttonEquile).Click += (sender, e) =>
{
try
{
decimal secondNumber = Convert.ToDecimal(inputOutput.Text);
decimal result = 0;
switch (operation)
//.........这里部分代码省略.........
示例10: 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()); // 将光标移动最后一个字符后面
}
示例11: Init
//.........这里部分代码省略.........
textTextView.AfterTextChanged -= afterTextChanged;
textTextView.Text = newText;
textTextView.TextChanged += textChanged;
textTextView.BeforeTextChanged += beforeTextChanged;
textTextView.AfterTextChanged += afterTextChanged;
};
afterTextChanged = (sender, args) =>
{
var length = args.Editable.ToString().Length;
var deleting = beforeTextSize == 1;
if (deleting)
{
nextMustBeDeleted = false;
}
else
{
if (nextMustBeDeleted && length > 0)
{
updateTextView(args.Editable.SubSequence(0, length - 1));
UpdateHintTextForCurrentTextEntry();
return;
}
}
// If we are deleting (we've just removed a space char, so delete another char please:
// Or if we've pressed space don't allow it!
if ((deleting && skipCharsAtPositions.Contains(length)) ||
(length > 0 && IsCharInFilter(args.Editable.CharAt(length - 1)) &&
!skipCharsAtPositions.Contains(length - 1)))
{
updateTextView(length == 0 ? "" : args.Editable.SubSequence(0, length - 1));
textTextView.SetSelection(length == 0 ? 0 : length - 1);
UpdateHintTextForCurrentTextEntry();
return;
}
// Adds a non numeric char at positions needed
for (int i = 0; i < skipCharsAtPositions.Count; ++i)
{
// We rescan all letters recursively to catch when a users pastes into the edittext
int charPosition = skipCharsAtPositions[i];
if (length > charPosition)
{
if (hintText[charPosition] != args.Editable.ToString()[charPosition])
{
updateTextView(args.Editable.SubSequence(0, charPosition) + "" + hintText[charPosition] +
args.Editable.SubSequence(charPosition, args.Editable.Length()));
UpdateHintTextForCurrentTextEntry();
return;
}
}
else
{
if (length == charPosition)
{
updateTextView(textTextView.Text + "" + hintText[charPosition]);
}
}
}
UpdateHintTextForCurrentTextEntry();
// We've got all the chars we need, fire off our listener
if (length >= LengthToStartValidation())
{
try
{
ValidateInput(args.Editable.ToString());
if (OnEntryComplete != null)
{
OnEntryComplete(args.Editable.ToString());
}
return;
}
catch (Exception exception)
{
Log.Error(JudoSDKManager.DEBUG_TAG, exception.Message, exception);
}
ShowInvalid();
}
else
{
if (OnProgress != null)
{
OnProgress(length);
}
}
};
textTextView.BeforeTextChanged += beforeTextChanged;
textTextView.TextChanged += textChanged;
textTextView.AfterTextChanged += afterTextChanged;
}
示例12: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
RequestWindowFeature(WindowFeatures.NoTitle);
SetContentView(Resource.Layout.Login);
if (SysVisitor.getVersionCode(this) != -1)
{
_publicfuns.of_SetMySysSet("app", "vercode", SysVisitor.getVersionCode(this).ToString());
}
if (SysVisitor.getVersionName(this) != "")
{
_publicfuns.of_SetMySysSet("app", "vername", SysVisitor.getVersionName(this));
}
_publicfuns.of_SetMySysSet("phone", "meid", SysVisitor.MEID(this));
#region 自动登录
if (_publicfuns.of_GetMySysSet("Login", "Login") == "Y")
{
string ls_user = _publicfuns.of_GetMySysSet("Login", "username");
string ls_pwd = _publicfuns.of_GetMySysSet("Login", "password");
string ls_logindate = _publicfuns.of_GetMySysSet("Login", "logindate");
if (!string.IsNullOrEmpty(ls_user) && !string.IsNullOrEmpty(ls_pwd))
{
DateTime time;
try
{
time = Convert.ToDateTime(ls_logindate);
}
catch
{
time = DateTime.Now.AddDays(-100);
}
if (SysVisitor.DateDiff(time.ToString(), SysVisitor.timeSpan.Days) <= 7)
{
SysVisitor.UserName = ls_user;
Intent it = new Intent();
Bundle bu = new Bundle();
bu.PutString("name", "data");
bu.PutString("update", "");
it.PutExtras(bu);
it.SetClass(this.ApplicationContext, typeof(Index));
StartActivity(it);
Finish();
return;
}
}
}
#endregion
string ls_DeviceId = SysVisitor.MEID(this);
#region 初始化控件
spinner = FindViewById<Spinner>(Resource.Id.login_company);
spinner_mygroup = FindViewById<Spinner>(Resource.Id.login_group);
username = FindViewById<Spinner>(Resource.Id.login_username);
btn_cancel = FindViewById<Button>(Resource.Id.login_cancel);
btn_login = FindViewById<Button>(Resource.Id.login_submit);
Refresh = FindViewById<TextView>(Resource.Id.login_Refresh);
password = FindViewById<EditText>(Resource.Id.login_pass);
chk_showpwd = FindViewById<CheckBox>(Resource.Id.login_showpwd);//显示密码
chk_login = FindViewById<CheckBox>(Resource.Id.login_checklogin);//自动登录
text = FindViewById<TextView>(Resource.Id.login_text);//底部说明文字
#endregion
int li_row = SqliteHelper.ExecuteNum("select count(*) from customer");
if (li_row <= 0)
{
text.Text = "首次登陆时需要从服务器获取大量数据\n可能需要几分钟甚至更长时间\n建议在网络条件较好的环境下操作\n获取数据过程中请不要关闭程序";
}
string CompanyList = _publicfuns.of_GetMySysSet("Login", "CompanyList");
string CompanyHost = _publicfuns.of_GetMySysSet("Login", "CompanyHost");
//未获取到本地数据 从服务器获取
if (string.IsNullOrEmpty(CompanyList) || string.IsNullOrEmpty(CompanyHost))
{
Intent it = new Intent();
Bundle bu = new Bundle();
bu.PutString("name", "login");
it.PutExtras(bu);
it.SetClass(this.ApplicationContext, typeof(Loading));
StartActivity(it);
Finish();
return;
}
string[] list = { };
if (CompanyList.Substring(0, 2) == "OK")
{
list = CompanyList.Substring(2).Split(',');
}
if (CompanyHost.Substring(0, 2) == "OK")
{
_publicfuns.of_SetMySysSet("Login", "CompanyHost", CompanyHost);
}
#region 为控件绑定数据
var adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
for (int i = 0; i < list.Length; i++)
{
adapter.Add(list[i]);
}
spinner.Adapter = adapter;
spinner.SetSelection(list.Length - 1, true);//默认选中项
//.........这里部分代码省略.........
示例13: ConfigureInput
private void ConfigureInput(EditText input, InputType type)
{
input.InputType = GetInputTypes(type);
var text = input.Text;
if (!string.IsNullOrEmpty(text))
input.SetSelection(text.Length);
input.SetSingleLine(true);
}