本文整理汇总了C#中EditText.SetFilters方法的典型用法代码示例。如果您正苦于以下问题:C# EditText.SetFilters方法的具体用法?C# EditText.SetFilters怎么用?C# EditText.SetFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditText
的用法示例。
在下文中一共展示了EditText.SetFilters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Display
public void Display (string body, string title, GoalsAvailable availableGoal, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null)
{
EditText goalTextBox = new EditText (Forms.Context);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Forms.Context);
alertDialogBuilder.SetTitle (title);
alertDialogBuilder.SetMessage (body);
alertDialogBuilder.SetView (goalTextBox);
goalTextBox.InputType = Android.Text.InputTypes.NumberFlagSigned;
var inputFilter = new Android.Text.InputFilterLengthFilter (7);
var filters = new Android.Text.IInputFilter[1];
filters [0] = inputFilter;
goalTextBox.SetFilters (filters);
goalTextBox.InputType = Android.Text.InputTypes.ClassNumber;
alertDialogBuilder.SetPositiveButton ("OK", (senderAlert, args) => {
if(action != null)
{
int goalValue;
int.TryParse(goalTextBox.Text, out goalValue);
action.Invoke(availableGoal, goalValue);
}
} );
alertDialogBuilder.SetNeutralButton ("CANCEL", (senderAlert, args) => {
} );
alertDialogBuilder.Show ();
}
示例2: 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;
}
示例3: OnCreate
//--------------------------------------------------------------
// EVENT CATCHING METHODS
//--------------------------------------------------------------
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
RequestWindowFeature(WindowFeatures.NoTitle);
Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
SetContentView(Resource.Layout.Dialog);
_root = FindViewById<LinearLayout>(Resource.Id.alertContainer);
_root.SetPadding(Builder.StrokeBorderWidth, Builder.StrokeBorderWidth, Builder.StrokeBorderWidth, Builder.StrokeBorderWidth);
_root.SetMinimumWidth ((int)(WindowManager.DefaultDisplay.Width * MinWidthRatio));
_root.SetMinimumHeight((int)(WindowManager.DefaultDisplay.Height * MinHeightRatio));
if(_root.ViewTreeObserver.IsAlive)
{
_root.ViewTreeObserver.AddOnGlobalLayoutListener(this);
}
_title = FindViewById<TextView>(Resource.Id.alertTitle);
_title.SetTextColor(Builder.StrokeColor);
_title.Gravity = GravityFlags.CenterHorizontal;
if(String.IsNullOrEmpty(Builder.Title))
{
_title.Visibility = ViewStates.Gone;
}
else
{
_title.Text = Builder.Title;
}
_content = FindViewById<LinearLayout>(Resource.Id.alertContent);
switch (Builder.ContentType)
{
case DialogBuilder.DialogContentType.TextView:
if(!String.IsNullOrEmpty(Builder.Message))
{
_message = new TextView(this);
_message.Text = Builder.Message;
_message.SetTextSize(Android.Util.ComplexUnitType.Dip, TextSize);
_message.SetTextColor(Builder.TextColor);
_message.Gravity = GravityFlags.CenterHorizontal;
_content.AddView(_message, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
}
break;
case DialogBuilder.DialogContentType.EditText:
_field = new EditText(this);
_field.Hint = Builder.Message;
_field.SetTextSize(Android.Util.ComplexUnitType.Dip, TextSize);
// Limit the length
_field.SetFilters( new IInputFilter[] { new InputFilterLengthFilter(Constants.MaxLengthName) } );
_content.AddView(_field, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
break;
case DialogBuilder.DialogContentType.None:
foreach(View view in Builder.Content)
{
_content.AddView(view, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
}
break;
default:
break;
}
_buttonLayout = FindViewById<LinearLayout>(Resource.Id.buttonLayout);
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) _buttonLayout.LayoutParameters;
lp.TopMargin = Builder.StrokeBorderWidth;
_buttonLayout.LayoutParameters = lp;
_positiveButton = FindViewById<ButtonStroked>(Resource.Id.positiveButton);
_negativeButton = FindViewById<ButtonStroked>(Resource.Id.negativeButton);
if(String.IsNullOrEmpty(Builder.PositiveText) && String.IsNullOrEmpty(Builder.NegativeText))
{
_positiveButton.Visibility = ViewStates.Gone;
_negativeButton.Visibility = ViewStates.Gone;
}
else if(String.IsNullOrEmpty(Builder.PositiveText))
{
_positiveButton.Visibility = ViewStates.Gone;
LinearLayout.LayoutParams lpNeg = (LinearLayout.LayoutParams) _negativeButton.LayoutParameters;
lpNeg.Weight = 2;
_negativeButton.LayoutParameters = lpNeg;
}
else if(String.IsNullOrEmpty(Builder.NegativeText))
{
_negativeButton.Visibility = ViewStates.Gone;
LinearLayout.LayoutParams lpPos = (LinearLayout.LayoutParams) _positiveButton.LayoutParameters;
lpPos.Weight = 2;
_positiveButton.LayoutParameters = lpPos;
}
else
{
LinearLayout.LayoutParams lpPos = (LinearLayout.LayoutParams) _positiveButton.LayoutParameters;
lpPos.LeftMargin = Builder.StrokeBorderWidth/2;
_positiveButton.LayoutParameters = lpPos;
LinearLayout.LayoutParams lpNeg = (LinearLayout.LayoutParams) _negativeButton.LayoutParameters;
lpNeg.RightMargin = Builder.StrokeBorderWidth/2;
_negativeButton.LayoutParameters = lpNeg;
//.........这里部分代码省略.........
示例4: SetEditTextMaximumLength
public void SetEditTextMaximumLength(EditText edittext,int value)
{
global::Android.Text.IInputFilter[] filter = new global::Android.Text.IInputFilter[1];
filter[0] = new global::Android.Text.InputFilterLengthFilter(value);
edittext.SetFilters (filter);
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
//RequestWindowFeature(WindowFeatures.NoTitle);
base.OnCreate (bundle);
SetContentView (Resource.Layout.Pay_SMS_Main);
sendSMS_btn = FindViewById<Button> (Resource.Id.sendSMS);
numberEditText = FindViewById<EditText> (Resource.Id.editText_number);
numberEditText.Text = GeoFencer.inZone ();
listView = FindViewById<ListView> (Resource.Id.List_SMS_Main_History);
listView.ItemClick += OnListItemClick;
messageEditText = FindViewById<EditText> (Resource.Id.editText_message);
//prikazuje sva slova kao velika.(upper) i ogranicava velicinu registracije na registrationLength
messageEditText.SetFilters (new IInputFilter[] { new InputFilterAllCaps (),new InputFilterLengthFilter (registrationLength) });
var prefs = Application.Context.GetSharedPreferences("MySharedPrefs", FileCreationMode.Private);
const int regaPicDefault=Resource.Drawable.ociscena_rega;
messageEditText.SetBackgroundResource ( prefs.GetInt("MyRegistrationPrefs",regaPicDefault ));
try{
messageEditText.Text = prefs.GetString ("MyRegistrationDefaultPrefs", "");
//Log.Debug ("defaultna rega",messageEditText.Text);
}catch(Exception e){
Log.Debug ("Nema registracije na izbor",e.ToString ());
}
#region Ucitava podatke iz datoteke svaki put kad se otvori layout Pay_SMS_Main
//Log.Debug ("ON CREATE","DULJINA"+new FileInfo(message_Data).Length+" -- "+Enable_message_update);
long duljina=0;
try{
duljina = new FileInfo (message_Data).Length;
}catch(Exception e){
Log.Debug ("Pay_SMS_Main","FILE INFO krivo učitava "+e.ToString ());
}
if (duljina != 0 || Fill_ListView_With_Data.update_inbox_messages==true) {
List<string> data = new List<string> ();
String line;
StreamReader reader = new StreamReader (message_Data);
while ((line=reader.ReadLine ()) != null) {
data.Add (line);
}
reader.Close ();
podaciDialogLista=data;
try{
Fill_ListView_With_Data.FillListWithData (data,this,listView);
}
catch(NullReferenceException e){
Log.Debug ("FillListWithData:Na pocetku Pay_SMS_Main", e.ToString ());
}
}else{
Fill_ListView_With_Data.DeleteHistory ();
}
#endregion
//if user enabled Inbox messages
if(Fill_ListView_With_Data.Enable_message_update==true){
Fill_ListView_With_Data.Fill_With_Inbox_Data (this,listView);
}
try{
var tuple=ParseZoneNumbers.LoadZoneNumbersAssetsData (this);
zone = tuple.Item1; //zone
zoneDictionary = tuple.Item2; // zone i pripadni stringovi
}catch(Exception e){
Log.Debug ("Greska prilikom ucitavanja zone i zoneDictionary u Pay_SMS_Main",e.ToString ());
}
//dodavanje metode EventHandler delegatu iz OnReceiveSMS
//OnReceiveSMS.ReceiveSMSmessage += new OnReceiveSMS.ReceiveSMSdelegate (EventHandler);
//spremanje popisa brojeva zona u memoriju
var prefsZone = Application.Context.GetSharedPreferences("MySharedPrefs", FileCreationMode.Private);
var prefsZoneEditor = prefsZone.Edit ();
prefsZoneEditor.PutStringSet("MyZonePrefs", zone);
prefsZoneEditor.Commit();
//spremanje dictionarya zone-numbers u memoriju
var prefsDict = Application.Context.GetSharedPreferences("MySharedPrefs", FileCreationMode.Private);
var prefsDictEditor = prefsDict.Edit ();
string dict = string.Join (", ", zoneDictionary
.Select (m => m.Key + ":" + m.Value)
.ToArray ());
prefsDictEditor.PutString("MyDictPrefs", dict);
prefsDictEditor.Commit();
#region Button inicijalizacija zona i Click metoda
/*
* Inicijalizacija dugmova zona i postavljanje njihovog rada.
*/
Button vuki_btn = FindViewById<Button> (Resource.Id.zona01_btn);
//.........这里部分代码省略.........