Get text from dynamically created EditText on click of a button

对着背影说爱祢 提交于 2019-12-07 15:21:43

You are passing to the getOnClickDoSomething function the text of the newly created editText, so understandably it will be blank. What you may want is to change getOnClickDoSomething, so that it accepts reference to the editTexts themselves, and later you can retrieve the their current text. (You will have to be careful not to leak views, as you have anonymous classes holding on to the Views.)
Example: Just change the following lines as follows

bt_plus.setOnClickListener(getOnClickDoSomething(et_one, et_two)); }


View.OnClickListener getOnClickDoSomething(final EditText one1,final EditText two1) 


Log.e("========","=====one ="+one1.getText().toString().trim(),+"=========two = "+two1.getText().toString().trim()); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!