当我尝试打开某个活动时,应用程序崩溃

时间:2017-04-23 02:00:32

标签: android xml android-studio android-intent android-activity

大家好我是Android Studio的新手。我正在尝试构建一个应用程序,但是当我尝试打开某个Activity而其他活动打开时它会继续崩溃,只是第四个就是问题。

public class ForthActivity extends AppCompatActivity {

private EditText email;
private Button Save;

DatabaseReference databaseReference;

@Override
protected void onCreate (Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_forth);


   email = (EditText) findViewById(R.id.email);
    Save =(Button) findViewById(R.id.btnSave);

    databaseReference = FirebaseDatabase.getInstance().getReference().child("Users");


    Save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AddData();

        }
    });


}

public void AddData(){
    String Email = email.getText().toString().trim();

    SaveData saveData = new SaveData(Email);

    databaseReference.push().setValue(saveData);

}
}

0 个答案:

没有答案