With reference to the lunchlist example in "Android PRogramming Tutorials" by Mark L.Murphy, In the below static class code (page 84) :
static class RestaurantHolder {
private TextView name=null;
private TextView address=null;
private ImageView icon=null;
RestaurantHolder(View row) {
name=(TextView)row.findViewById(R.id.title);
address=(TextView)row.findViewById(R.id.address);
icon=(ImageView)row.findViewById(R.id.icon);
}
void populateFrom(Restaurant r) {
name.setText(r.getName());
address.setText(r.getAddress());
if (r.getType().equals("sit_down")) {
icon.setImageResource(R.drawable.ball_red);
}
else if (r.getType().equals("take_out")) {
icon.setImageResource(R.drawable.ball_yellow);
}
else {
icon.setImageResource(R.drawable.ball_green);
}
}
}
I'm trying to replace
r.getType().equals("take_out")
with
r.getType().equals(getString(R.string.TakeAway))
but I'm getting the error "Cannot make a static reference to the non-static method getString(int) from the type Context"
Sorry it's probably a silly question but i really need help.
if you want to get string in such way, you can try something like this: