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

Android Build a Blog Reader Android App Rebuilding from Scratch Adding Data for the List

Christina Nairn
PLUS
Christina Nairn
Courses Plus Student 5,239 Points

Declare an array of Strings as a member variable of the MainListActivity class.

I would love some help. I cannot seem to make my code work on the Android Development Course Stage 2, Rebuilding from Scratch. If someone could point out the errors in my code that would be much appreciated.

The question is "Declare an array of Strings as a member variable of the MainListActivity class. Name it 'mSongTitles', make it 'public', and initialize it with at least three values."

My answer is:

public class MainListActivity extends ListActivity { public String[] mSongTitles = {"Songs", "The Blues", "Song Bird", "Song Sung Blue"}; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_list); }

}

The errors I am getting are: ./com/example/MainListActivity.java:13: error: class, interface, or enum expected public void onCreate(Bundle savedInstanceState) { ^ ./com/example/MainListActivity.java:15: error: class, interface, or enum expected setContentView(R.layout.activity_main_list); ^ ./com/example/MainListActivity.java:16: error: class, interface, or enum expected } ^ 3 errors

1 Answer

Jaroslav Vankat
Jaroslav Vankat
12,054 Points

The second bracket ('}') does not make sense there, you are closing the ListActivity with that.

Christina Nairn
Christina Nairn
Courses Plus Student 5,239 Points

oooo my gosh, it was that simple. Thank you so much for your time Jaroslav, very much appreciated.