天蓬老师2017-04-17 17:01:18
It reminds you that the place where this thing is referenced is only in one method (that is, in onCreate), and other methods and external classes do not reference it.
So, you can turn it into a temporary variable and put it in that method.
According to your situation, Android Studio wants you to put this variable in onCreate and does not need to be a member variable of Activity.
Generally speaking, I usually hold things like this View as member variables instead of temporary variables. For the sake of code consistency, if I want to adjust the properties of the View one day, I don’t need to declare it as a member variable again. Okay trouble.
迷茫2017-04-17 17:01:18
It means that you can make it a member variable~or if you write a method and use it, there will be no warning
PHP中文网2017-04-17 17:01:18
Because although you assigned a value to it, you have not used this private variable.
PHP中文网2017-04-17 17:01:18
The subject’s understanding of the question needs to be improved...
The prompt means that these members are declared but not used. The lines in create only assign values to the members, which is not called use. The reason why the button does not prompt is because the setonclicklistener method is accessed and called later, which is called use.
As for textview, it should be accessed elsewhere. The screenshot code snippet is limited and I can’t see where it is called
In addition, the statement "newly created and instantiated" in the question seems to be a pain in the ass. It only holds a reference to a view that has been automatically instantiated through assignment...