Mark L.Murphy による「Android PROgramming Tutorials」の lunchlist の例を参照して、以下の静的クラス コード (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);
}
}
}
交換しようとしています
r.getType().equals("take_out")
と
r.getType().equals(getString(R.string.TakeAway))
しかし、「型 Context から非静的メソッド getString(int) への静的参照を作成できません」というエラーが表示されます
ばかげた質問かもしれませんが、本当に助けが必要です。