Question: Hello I am having errors with my android studio code.It is a gps code. It is using api 2 7 and it has a lot

Hello I am having errors with my android studio code.It is a gps code. It is using api 27 and it has a lot of underline erros and I will leave the code down below and give you a screenshot of how it looks like. Can you please help this code be able to run?
code:
package com.example.mygps;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Setup window insets
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main),
(v, insets)->{
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
// onClickListener for Button Click
findViewById(R.id.addLocationButton).setOnClickListener(view ->{
Intent intent = new Intent(MainActivity.this, AddLocationActivity.class);
startActivity(intent);
});
}
}
class Location {
private String name;
private String country;
private String gpsCoordinates;
private String visitDate;
private int rating;
// Constructor
public Location(String name, String country, String gpsCoordinates, String visitDate, int rating){
this.name = name;
this.country = country;
this.gpsCoordinates = gpsCoordinates;
this.visitDate = visitDate;
this.rating = rating;
}
// Getters and setters
public String getName(){
return name;
}
public String getCountry(){
return country;
}
public String getGpsCoordinates(){
return gpsCoordinates;
}
public String getVisitDate(){
return visitDate;
}
public int getRating(){
return rating;
}
}
public class AddLocationActivity extends AppCompatActivity {
private EditText editTextName, editTextCountry, editTextGPS, editTextDate;
private NumberPicker ratingPicker;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_location);
// Initialize views
editTextName = findViewById(R.id.editTextName);
editTextCountry = findViewById(R.id.editTextCountry);
editTextGPS = findViewById(R.id.editTextGPS);
editTextDate = findViewById(R.id.editTextDate);
ratingPicker = findViewById(R.id.ratingPicker);
// Configure NumberPicker
ratingPicker.setMinValue(1);
ratingPicker.setMaxValue(5);
// Set up save button
findViewById(R.id.saveButton).setOnClickListener(view ->{
String name = editTextName.getText().toString();
String country = editTextCountry.getText().toString();
String gps = editTextGPS.getText().toString();
String date = editTextDate.getText().toString();
int rating = ratingPicker.getValue();
// Display a Toast message for now
Toast.makeText(this, "Location saved: "+ name, Toast.LENGTH_SHORT).show();
});
}
}
Hello I am having errors with my android studio

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!