How to get text from EditText?

前端 未结 7 1620
北恋
北恋 2021-01-01 12:14

The question is quite simple. But I want to know where exactly do we make our references to the gui elements? As in which is the best place to define:

final          


        
7条回答
  •  我在风中等你
    2021-01-01 12:35

    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 idea
    Probably the reason for your nulls is that you are trying to call findViewById() before you set contentView() in your onCreate() method - please check that.

提交回复
热议问题