0

Errors:

  1. Could not execute method for android:onCli at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick"

  2. Caused by: java.lang.reflect.InvocationTargetException

  3. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference at com.stunner.mobicoach.MainActivity.btnAddData(MainActivity.java:152)

------------------code------------------

public void btnAddData (View v){
    String name = etName.getText().toString();
    String surname = etSurname.getText().toString();
    String position = etPosition.getText().toString();
    Person person = new Person(name,surname,position);
    persons.add(person);

    setTextToTextView();
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Thamie
  • 1
  • 2

2 Answers2

0

etName or etSurname or etPosition is Null means their object you didn't create

Shubham
  • 521
  • 4
  • 11
0

Check if you have find the view by id in your java code. i.e.

edtName = (EditText)findViewById(R.id.yourEditBoxId);

Check this line for all editboxes, missing this can be the cause of your problem.

intellignt_idiot
  • 1,962
  • 2
  • 16
  • 23