samedi 9 mai 2015

Why do my initializations in Android Studio do nothing?

I'm just getting in to android developing and I've been having the same problems when it comes to initializing just about anything before use. My app always crashes due to trying to use methods on a null object even though I initialize it like people do on other questions asked on this site.

ll=(LinearLayout) findViewById(R.id.slider);

Why is this line not working in my onCreate? I have private LinearLayout ll; earlier in the code but for some reason it does nothing. I had a similar problem with an EditText that I used a view that I made equal to an inflator but that doesn't seem to work in this context. I'm just confused as to why that line above works for everyone but me. slider is the name of another LinearLayout in an xml file.

Aucun commentaire:

Enregistrer un commentaire