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
Arnaud Schenk
Courses Plus Student 2,957 PointsAll About @string Resources ADT discrepancies (solved)
EDIT: a quit and restart fixed it.
Hey,
I'm following the "Build a blog reader" course for android, and in the video named "All About @string Resources", they tell us about 10 minutes in about getStringArray.
I'm having issues with the parameter that we are asked to input. In the course, R.array.android_names is used, but in ADT, the "array" keyword throws an error. Is there a new way of doing this ?
Here is my code so far:
package com.arnaudschenk.blogreader;
import android.app.ListActivity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
public class MainListActivity extends ListActivity {
protected String[] mAndroidNames;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_list);
Resources resources = getResources();
mAndroidNames = resources.getStringArray(R.array.android_names);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mAndroidNames);
setListAdapter(adapter);
//String message = getString(R.string.no_items);
//Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_list, menu);
return true;
}
}
1 Answer
Ben Jakuben
Treehouse TeacherGlad to see you got this fixed. Sadly, sometimes restarting Eclipse is the best answer. :-/