Brandon Edge

+ Follow
since Sep 04, 2019
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brandon Edge

started making a simple oil changing app but I've hit a wall with it. I'm not sure if it a fault in my logic or code. You add a car to the app with it's details these go into an array list and the car is displayed on a card view on the main screen showing the name, make, model, etc. When you click on a car from the main screen it opens another screen populated with the car and details with a list of existing oil changes and a button to add new oil change. When an oil change is added it creates another list containing details on the oil change including the name of the car. I have it so whichever car you pick from the main screen shows its own oil change history. The problem I can't figure out is, I preform a simple calculation to show when the next oil change is due based on miles I would like this value to be displayed on the main screen car card. I can pass a value to the card but the same value keeps going to every car I have listed. I can't figure out how to tie the mileage due value to the correct car.

adding a car

adding an oil change

Where I populate the oil change on cars card but it goes to all cars

Display car cards and open new activity when car clicked

i was given this advice on another site and i've tried to follow it but now when my app launches it crashes i get an null object reference
i'm pretty sure it's the oilChange array from this line but i don't know how to fix it.

1) Create an extra field in the Car model

private String changeOil;
//create setter and getter for changeOil
then obtain the current car to be updated and update the changeOil of the car while saving the oilChange in adding oil change

2) Pass the OilChange array list to the CarAdapter

ArrayList<OilChange> oliChanges;

public CarAdapter(Context context, int resource, ArrayList<Cars> cars, ArrayList<OilChange> oilChanges) {
   super(context, resource, cars);
    this.oilChanges = oilChanges;


Cars cars = getItem(position);
OilChange oilChange = oilChanges.get(position);
   if(cars != null){
       TextView txtName = convertView.findViewById(;
       TextView txtMake = convertView.findViewById(;  //from car_list reads what's there (i think)
       TextView txtModel =convertView.findViewById(;
       TextView txtMiles = convertView.findViewById(;
       TextView txtOilChangeDue = convertView.findViewById(;
      // TextView txtOilChangeDueMiles = convertView.findViewById(;


//obtain the oilchange from the model ensure you have created a getOilChange() method in OilChange class to obtain the oilchange
       txtOilChangeDue.setText(oilChange.getOilChange());  //replaces value each time and on
2 weeks ago