单击时保存数据库,但单击时不进入下一个类

时间:2018-07-03 05:21:26

标签: java android firebase firebase-realtime-database

public class JobSignup extends AppCompatActivity {

private Button btn;
private ImageView imageview;
private static final String IMAGE_DIRECTORY = "/demonuts";
private int GALLERY = 1, CAMERA = 2;


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


    FirebaseDatabase database = FirebaseDatabase.getInstance();
    final DatabaseReference myRef = database.getReferenceFromUrl("https://rozgarinepal100.firebaseio.com/");


    final TextView userName = (TextView) findViewById(R.id.userName);

    final EditText writeName = (EditText) findViewById(R.id.writeName);

    ImageButton sendDataToFirebase = (ImageButton) findViewById(R.id.sendDataToFirebase);

    final TextView dateOfBirth = (TextView) findViewById(R.id.dateOfBirth);
    final EditText enterDateOfBirth = (EditText) findViewById(R.id.enterDateOfBirth);

    if ( writeName.getText().toString().length() == 0)
    {
        writeName.setError("Username Compulsory");
    }

//        if( TextUtils.isEmpty(writeName.getText())) {
//            /**
//             *   You can Toast a message here that the Username is Empty
//             **/
//
//            writeName.setError("First name is required!"); 
//
//        }


    sendDataToFirebase.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            myRef.child("0").child(userName.getText().toString()).setValue(writeName.getText().toString());
            //myRef.child("NAME:").setValue("Kathmandu University");

            myRef.child("0").child(dateOfBirth.getText().toString()).setValue(enterDateOfBirth.getText().toString());


        }
    });
}

public void onClick(View v) {
    Intent i = new Intent(this, HomeActivity.class);
    startActivity(i);
   }
 }

我的代码运行良好,并且在单击时也保存了数据库,但单击时不会使用intent。在onclick侦听器函数中,我在android.Database上单击按钮时为数据库添加了链接。单击操作运行良好,但我无法进入我创建的下一课。单击同一按钮时,我只有一个问题可以进入下一课。我正在尝试启用数据库并转到下一课使用相同的按钮。

1 个答案:

答案 0 :(得分:0)

尝试一下,它将起作用...

--config = cuda  #cuda library link is happening through run time
相关问题