このエラーの修正方法を教えてください。私はそれを得ることができない。シンボル 'v'と期待通りに解決できません)。
私はこの部分にエラーがありました。
signup.setOnClickListener((v) → {
String uName = username.getText().toString().trim();
String mail = email.getText().toString().trim();
String pass = password.getText().toString().trim();
signup(uName, mail, pass);
});
全体コード:
public class SignUp extends AppCompatActivity {
private String TAG = SignUp.class.getSimpleName();
private EditText username, email, password;
private Button signup;
private ProgressDialog progressDialog;
private UserSession session;
private UserInfo userInfo;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
username = (EditText) findViewById(R.id.username);
email = (EditText) findViewById(R.id.email);
password = (EditText) findViewById(R.id.password);
signup = (Button) findViewById(R.id.signup);
progressDialog = new ProgressDialog(this);
GoogleApiClient client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
session = new UserSession(this);
userInfo = new UserInfo(this);
signup.setOnClickListener((v) → {
String uName = username.getText().toString().trim();
String mail = email.getText().toString().trim();
String pass = password.getText().toString().trim();
signup(uName, mail, pass);
});
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client2 = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
private void signup(final String username, final String email, final String password) {
//Tag used to cancel the request
String tag_string_req = "req_signup";
progressDialog.setMessage("Signing up...");
progressDialog.show();
StringRequest strReq = new StringRequest(Request.Method.POST,
Utils.REGISTER_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Register Response: " + response.toString());
try {
JSONObject jOBj = new JSONObject(response);
boolean error = jOBj.getBoolean("error");
//Check for error node in json
if (!error) {
JSONObject user = jOBj.getJSONObject("user");
String uName = user.getString("username");
String email = user.getString("email");
//Inserting row in users table
userInfo.setEmail(email);
userInfo.setUsername(uName);
session.setLoggedin(true);
startActivity(new Intent(SignUp.this, MainActivity.class));
} else {
//Error in login. Get the error message
String errorMsg = jOBj.getString("error_msg");
toast(errorMsg);
}
} catch (JSONException e) {
//JSON error
e.printStackTrace();
toast("Json error: " + e.getMessage());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Login Error: " + error.getMessage());
toast("Unknown Error occured");
progressDialog.hide();
}
}) {
@Override
protected Map<String, String> getParams() {
//posting parameters to login url
Map<String, String> params = new HashMap<>();
params.put("username", username);
params.put("email", email);
params.put("password", password);
return params;
}
};
}
private void toast(String x) {
Toast.makeText(this, x, Toast.LENGTH_SHORT)
}
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
public Action getIndexApiAction() {
Thing object = new Thing.Builder()
.setName("SignUp Page") // TODO: Define a title for the content shown.
// TODO: Make sure this auto-generated URL is correct.
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
.build();
return new Action.Builder(Action.TYPE_VIEW)
.setObject(object)
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
.build();
}
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client2.connect();
AppIndex.AppIndexApi.start(client2, getIndexApiAction());
}
@Override
public void onStop() {
super.onStop();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
AppIndex.AppIndexApi.end(client2, getIndexApiAction());
client2.disconnect();
}
}
のplsは何が起こっているのかを説明します。
あなたは他のソースからプロジェクトにこれを再入力したのですか? – TruongHieu
なぜPHPにタグ付けしたのですか?私は何も見ません。 –
Java 8以前のバージョンを使用していますか?そしてあなたは本当にあなたのコードに '→'を持っていましたか、それとも ' - ' 'でしたか? –