android edittext onchange listener

前端 未结 9 2211
长情又很酷
长情又很酷 2020-11-27 13:28

I know a little bit about TextWatcher but that fires on every character you enter. I want a listener that fires whenever the user finishes editing. Is it possib

9条回答
  •  无人及你
    2020-11-27 13:46

    TextWatcher didn't work for me as it kept firing for every EditText and messing up each others values.

    Here is my solution:

    public class ConsultantTSView extends Activity {
        .....
    
        //Submit is called when I push submit button.
        //I wanted to retrieve all EditText(tsHours) values in my HoursList
    
        public void submit(View view){
    
            ListView TSDateListView = (ListView) findViewById(R.id.hoursList);
            String value = ((EditText) TSDateListView.getChildAt(0).findViewById(R.id.tsHours)).getText().toString();
        }
    }
    

    Hence by using the getChildAt(xx) method you can retrieve any item in the ListView and get the individual item using findViewById. And it will then give the most recent value.

提交回复
热议问题