public CodeCompletionInput(Context context, IAttributeSet attrs) : base(context, attrs) { _context = context; Threshold = 0; _lastKeyPressed = null; _textWatcher = new TextWatcher(); _textWatcher.TextChanged += onTextChanged; AddTextChangedListener(_textWatcher); KeyPress += onKeyPress; SetSingleLine(false); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); editSearch = view.FindViewById <EditText>(Resource.Id.editSearch); buttonCancel = view.FindViewById(Resource.Id.buttonCancel); buttonCancel.Click += (o, e) => Dismiss(); TextWatcher textWatcher = new TextWatcher(); textWatcher.TextChanging += TextWatcher_TextChanging; editSearch.AddTextChangedListener(textWatcher); recyclerView = view.FindViewById <RecyclerView>(Resource.Id.rvListEditText); layoutManager = new LinearLayoutManager(Activity); recyclerView.SetLayoutManager(layoutManager); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.NoteLayout); Init(); SqlHelper = new Databasehelper(this); Db = SqlHelper.WritableDatabase; EditText.SetPadding(40, 10, 40, 10); textWatcher = new TextWatcher(EditText); EditText.AddTextChangedListener(textWatcher); notifyFragment = new NotifyFragment(EditText.EditableText, Args); Args = Intent.Extras; if (Args != null) { NoteNumber = Convert.ToInt32(Args.GetString(Databasehelper.COLUMN_ID)); cursor = Db.RawQuery("Select * from " + Databasehelper.TEXTTABLE + " Where _id ==" + Args.GetString(Databasehelper.COLUMN_ID), null); cursor.MoveToFirst(); ISpanned text; if (Build.VERSION.SdkInt >= BuildVersionCodes.N) { text = Html.FromHtml(cursor.GetString(cursor.GetColumnIndex("ColumnText")), FromHtmlOptions.ModeCompact); } else { text = Html.FromHtml(cursor.GetString(cursor.GetColumnIndex("ColumnText"))); } EditText.SetText(text, EditText.BufferType.Editable); cursor = Db.RawQuery("Select *" + " from " + Databasehelper.CONTENTTABLE + " Where _id==" + Args.GetString(Databasehelper.COLUMN_ID), null); setImages(cursor); notifyFragment.Id = NoteNumber; } else { EditText.RequestFocus(); } }
public void addTextChangedListener(TextWatcher watcher) { }
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()); // 将光标移动最后一个字符后面 }