I'm new to Android. Android Studio always warns me about this but I do not know what it means.
Method invocation 'setOnClickListener' may produce 'java.lang.NullPointerException'
I'd like to better understand what it's all about and what logic to solve it. Thank you.
Here is my MainActivity snippet
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the content of the activity to use the activity_main.xml layout file
setContentView(R.layout.activity_main);
//Listener Button for Family
TextView family = (TextView) findViewById(R.id.family);
family.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
Intent familyIntent = new Intent(MainActivity.this, FamilyActivity.class);
startActivity(familyIntent);
}
});
}
}