I have some resources defined, e.g.:
<color name="lightGrey">#FFCCCCCC</color>
<integer name="KEY_POSITION_ARM">2</integer>
...and I have an ArrayAdapter displaying items to TextViews. I'm trying to access the values with code like:
keyPosition = getResources().getInteger(R.integer.KEY_POSITION_ARM);
moduleDataView.setTextColor(getResources().getColor(R.color.darkgreen));
...but I get errors like "The method getResources() is undefined for the type ContinuityAdapter". (ContinuityAdapter extends ArrayAdapter)
Is there a good way around this?
Thanks
This is an example:
switch (currentModule.keyPosition) {
case activity.getResources().getInteger(R.integer.KEY_POSITION_ARM):
moduleDataView.keyPosition.setText("TEST");
moduleDataView.keyPosition.setTextColor(Color.GREEN);
break;
case R.integer.KEY_POSITION_ARM:
moduleDataView.keyPosition.setText("ARM");
moduleDataView.keyPosition.setTextColor(Color.RED);
break;
}
The first case give an error, and the second doesn't but doesn't use the value from the XML file either. Although as you say I can just use the R... value as long as I use it that way everywhere. Just not sure if this is considered 'best practice'. Thanks