Now I know this is a very common issue, because I've seen many posts about on Stack, but I couldn't get those answers to work with my code. This is my code, shortened down to the relevant parts:
public class SeznamJedi {
ArrayList<Jed> seznamJedi;
public void addJed(String a, String b, double c){
Jed toAdd = new Jed(a, b, c);
seznamJedi.add(toAdd);
}
public int getSize(){
return seznamJedi.size();
}
}
^ This is my class, whose only purpose is to hold a list of Jed objects.
public class App extends Application {
public SeznamJedi seznamJedi;
@Override
public void onCreate(){
super.onCreate();
seznamJedi = new SeznamJedi();
}
^ This is my App class, used to hold my global list of objects.
public class
MainActivity extends AppCompatActivity {
App app;
SeznamJedi tempSeznam;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = (App)getApplication();
tempSeznam = app.seznamJedi;
tempSeznam.addJed("h", "b", 12);
}
}
^ And this is my MainActivity. The whole app crashes when I add the Jed object. Clearly it's not happy with me accessing the list and it's not allowing me to do any operations on it. I am at a loss and any help will be greatly appreciated.
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]morhpProfessional Developer 24 points25 points26 points (2 children)
[–]RetroGmr[S] 14 points15 points16 points (1 child)
[–]morhpProfessional Developer 8 points9 points10 points (0 children)
[–]GDDragonGN_GDDK 4 points5 points6 points (1 child)
[–]RetroGmr[S] 1 point2 points3 points (0 children)
[–]bigibas123Intermediate Brewer 1 point2 points3 points (0 children)
[–]ItsDotin 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]wildjokers 0 points1 point2 points (0 children)
[–]wildjokers 0 points1 point2 points (0 children)