How to get text from EditText?

Well, it depends on your needs. Very often I keep my references to widgets in activity (as a class fields) – and set them in onCreate method. I think that is a good ideaProbably the reason for your nulls is that you are trying to call findViewById() before you set contentView() in your onCreate() method – please check that.

android edittext onchange listener

First, you can see if the user finished editing the text if the EditText loses focus or if the user presses the done button (this depends on your implementation and on what fits the best for you). Second, you can’t get an EditText instance within the TextWatcher only if you have declared the EditText as … Read more

How do you close/hide the Android soft keyboard programmatically?

To help clarify this madness, I’d like to begin by apologizing on behalf of all Android users for Google’s downright ridiculous treatment of the soft keyboard. The reason there are so many answers, each different, for the same simple question is that this API, like many others in Android, is horribly designed. I can think … Read more