它显示的最后一个括号中缺少请说出解决方案 [英] In the last bracket it showing } missing please say the solution
本文介绍了它显示的最后一个括号中缺少请说出解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
package com.minitrue.chatbox;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.support.v7.widget.Toolbar;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.time.Instant;
import java.util.HashMap;
public class Register_Activity extends AppCompatActivity {
EditText username,email,password;
Button bregister;
FirebaseAuth auth;
DatabaseReference Reference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Register");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
username=findViewById(R.id.username);
email=findViewById(R.id.email);
password=findViewById(R.id.password);
bregister=findViewById(R.id.bregister);
auth= FirebaseAuth.getInstance();
bregister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String txt_username=username.getText().toString();
String txt_email=email.getText().toString();
String txt_password=password.getText().toString();
if (TextUtils.isEmpty(txt_username) | TextUtils.isEmpty(txt_email) | TextUtils.isEmpty(txt_password)) {
Toast.makeText(Register_Activity.this, "All Feilds Are Required", Toast.LENGTH_SHORT).show();
} else if (txt_password.length()<6 ) {
Toast.makeText(Register_Activity.this, "Password Must Be Of Atleast 6 Characters", Toast.LENGTH_SHORT).show();
}else {Register(txt_username,txt_email,txt_password);
}
}
});
}
private void Register(final String username, String email, String password) {
Task<authresult> authResultTask = auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<authresult>() {
@Override
public void onComplete(@NonNull Task<authresult> task) {
if (task.isSuccessful()) {
FirebaseUser firebaseUser = auth.getCurrentUser();
String userid = firebaseUser.getUid();
Reference = FirebaseDatabase.getInstance().getReference("Users").child(userid);
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("id", userid);
hashMap.put("username", username);
hashMap.put("imageURL", "default");
Reference.setValue(hashMap).addOnCompleteListener(new OnCompleteListener<void>() {
@Override
public void onComplete(@NonNull Task<void> task) {
if (task.isSuccessful()) {
Intent intent = new Intent(Register_Activity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK / Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
}
});
} else {
Toast.makeText(Register_Activity.this, "You Cannot Register With This Email Or Password", Toast.LENGTH_SHORT).show();
}
}
});
}
我的尝试:
搜索错误但未找到
What I have tried:
searched for error but not found
推荐答案
您最后错过了一个紧密的大括号。
但是,因为你的缩进遍布整个地方,很难看出它是否会丢失 - 你可能忘记终止如果
块,或方法,或者......好吧,真的。
首先整理你的代码,然后整齐,一致地缩进代码。
它应该比它缺少的地方要清楚得多。
You are missing a close curly bracket at the end.
However, because your indentation is all over the place, it's very hard to see if that's where it';s missing from - it could be you forgot to terminate anif
block, or a method, or ... well, anything really.
Start by tidying up your code, and getting it indented neatly and consistently.
It should be a lot clearer then where it is missing from.
Quote:
在最后一个括号中显示}缺少请说解决方案
In the last bracket it showing } missing please say the solution
解决方案是错误信息,它告诉你出了什么问题。源代码末尾缺少'}'。
学会正确缩进代码,显示其结构,有助于阅读和理解。它还有助于发现结构错误。
专业程序员的编辑器具有此功能以及其他功能,例如括号匹配和语法突出显示。
Notepad++主页 [ ^ ]
ultraedit [ ^ ]
这篇关于它显示的最后一个括号中缺少请说出解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文