Answer the question
In order to leave comments, you need to log in
When accessing the variable method invocation?
public class MainActivity extends AppCompatActivity {
TextView myText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myText = (TextView) findViewById(R.id.myText);
myText.setText("test"); //Method invocation 'myText.setText("test")' may produce 'java.lang.NullPointerException'
}
Answer the question
In order to leave comments, you need to log in
The IDE is telling you that there might not be myText in activity_main.xml. Then the variable will be null.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question