Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Uros Mitic
4,704 PointsfindViewById in a non-activity class?
Guys, i'am stuck on this for like a week... So i want to call a findViewById in a non-activity class.
EXP:
I got MainActivity and a AddCustomer activity.By pressing a button in a AddCustomer activity i want to make new TextView in a LinearLayout in MainActivity.When i do that now i'm getting nullExeption on this line:
mLinearLayout = (LinearLayout)findViewById(R.id.customerLinearLayout);
customerLinearLayout is a layout from MainActivity so i'am getting a null pointer exception because of this.How can I resolve this issue?