jjzjj

addTextChangedListener

全部标签

android - 我怎样才能让 EditText 发生变化?

我有一个EditText,我想在每次文本更改(输入每个字符)时通知我。我应该使用什么实现以及我应该覆盖什么功能? 最佳答案 在您的EditText上使用addTextChangedListener方法并使您的类实现或定义一个内部类来实现TextWatcher类:https://developer.android.com/reference/android/widget/TextView.html#addTextChangedListener(android.text.TextWatcher)

android - 在 XML 中指定 addTextChangedListener

有没有我可以指定TextChangedListener的EditText属性?我知道它有3个方法,所以我只想像下面这样指定属性值但是我遇到了编译错误。我可以用同样的方式添加点击监听器,所以我想知道文本更改有什么问题?我知道我可以在Java代码中获取特定时间的View并调用添加监听器,但是这个解决方案看起来非常丑陋。 最佳答案 Android的DataBindingLibrary现在支持为存在于View类中的setter生成xml属性。如果你启用了数据绑定(bind),你需要做的就是使用app命名空间(不要忘记声明命名空间),比如ap

android - 如何在 TableLayout 中添加 editText.addTextChangedListener

我的工作环境是Eclipseheliose,Android1.6我创建了一个成功添加列和行的tableLayout,每个单元格都有一个textView和一个EditText,我在访问每个单元格时遇到问题,需要将addTextChangedListener添加到单元格内的每个editText。所以我需要将英文文本更改为印度文本。请提出解决方案/***HerewearegoingtodefinethegridTheGridhas1.grid'svalueinthe*particularposition2.*/publicvoidsetGrid(){StringquestionNumber[

安卓:addTextChangedListener 运行不正常

我想对用户在EditText中键入内容使用react,所以我使用了addTextChangedListener方法。当用户键入单个字符时,onTextChanged代码正在运行,一切正常。因此,例如,如果用户键入“a”,则onTextChanged将开始运行。但是如果用户键入另一个字符,例如b,则不会调用onTextChanged。(EditText中的文本现在应该是“ab”)代码:et=(EditText)findViewById(R.id.edittextsearch);et.addTextChangedListener(newTextWatcher(){publicvoidaft

android - android ActionBar 中 EditText 上的 addTextChangedListener()

我将编辑文本作为操作栏中的操作项(实际上是ActionBarSherlock)。布局在它自己的xml中,一切正常,我可以轻松访问编辑文本的内容并进行更改。我想在此编辑文本上添加一个更改监听器。加载onCreateOptionsMenu(Menumenu)并填充菜单后,我创建了我的EditTextsearch=(EditText)findViewById(R.id.searchbar);//itsnameinaframelayout然后search.addTextChangedListener(newTextWatcher(){@OverridepublicvoidafterTextCh

android - EditText addTextChangedListener 仅用于用户输入

我有一个EditText,我可以在其中监听文本的变化:editText.addTextChangedListener(newTextWatcher(){@OverridepublicvoidbeforeTextChanged(CharSequences,intstart,intcount,intafter){}@OverridepublicvoidonTextChanged(CharSequences,intstart,intbefore,intcount){}@OverridepublicvoidafterTextChanged(Editables){//dostuff}});目前为

Android:两个 EditText 不能有两个 addTextChangedListener?

我正在尝试制作两个EditText,我在其中一个EditText中键入任何内容,我键入的文本将显示在另一个EditText上。privateEditTextinput_a;privateEditTextinput_b;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);input_a=(EditText)findViewById(R.id.input_a);input_b=(EditText)findV

Android 在 addTextChangedListener (edittext) 的某些情况下禁用正面按钮

这是我的对话框代码,如果编辑文本中的文本大小大于5,我想禁用肯定按钮,如果大小privatevoidmyDialog(Stringtitle){AlertDialog.Builderbuilder=newAlertDialog.Builder(context);//GetthelayoutinflaterLayoutInflaterinflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);ViewdialogView=inflater.inflate(R.layout.new_d

android - 在 Android 函数中设置 addTextChangedListener

我有5个addTextChangedListener用于5个编辑文本。我想在一个函数中自定义它们,这样我就必须传递editttext的id并在其上应用addTextChangedListener。我怎么能这样做我不明白这个.请帮我解决这个问题。代码mobileNumber.addTextChangedListener(newTextWatcher(){@OverridepublicvoidonTextChanged(CharSequences,intstart,intbefore,intcount){mobileNumber.setError(null);}@Overridepubli

android - addTextChangedListener 和 onTextChanged 总是在 Android Fragment 加载时被调用

我在AndroidFragment中有一个EditText。我在onCreateView方法中将addTextChangedListener附加到它。在addTextChangedListener中,我有一个onTextChanged方法。通过日志记录,我可以看到每次加载Fragment时,都会调用onTextChanged。为什么会这样?我只希望在用户实际更改EditText中的文本时调用它。这是我的代码:@OverridepublicViewonCreateView(finalLayoutInflaterinflater,finalViewGroupcontainer,Bundle
12