EDIT: woah ... somehow I replaced this question with another one I was asking about, glad there is this rollback function
this particular question is about the getter from my previous question
public class Impacts extends Activity implements View.OnClickListener
{
boolean[] impactsb = new boolean[] {false, false, false, false, false, false, false, false}-
public void onCreate (Bundle savedInstanceState)
{
super.onCreate(savedInstanceState)
...
String getImpacts ()
{
String[] impactsn = new String[length];
Resources myResources = this.getResources();
impactsn = myResources.getStringArray(R.array.impacts);
StringBuilder impactss = new StringBuilder();
for (int i = 0; i < length; i ++)
{
if (impactsb[i])
impactss.append(impactsn[i] + " | ");
}
if (String.valueOf(impactss) != "")
impactss.insert(0, "Impacts: ");
return String.valueOf(impactss);
}
with these errors:
Impacts(ContextWrapper).getResources() line: 80
Impacts.getImpacts() line: 78
The final bracket of the code is below:
@Override
public Resources getResources()
{
return mBase.getResources();
}
and this line of code, respectively:
impactsn = getResources().getStringArray(R.array.impacts);
here is my strings.xml (still relevant parts)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="impacts">
<item>GasOilChemical Pollutants</item>
<item>Ghost Fishing</item>
<item>Marsh Damage</item>
<item>Navigational Hazard</item>
<item>Shellfish Damage</item>
<item>Waste Pollution</item>
<item>Wildlife Entanglement</item>
<item>Other</item>
</string-array>
</resources>
Original itemi was the first element:
<item>Gas/Oil/Chemical Pollutants</item>
but fixed it, hoping that at least it would change the error if it did not fix the problem. but no, the same mistake. any help would be much appreciated, I'm not very familiar with using an array, especially getting resources for an array.
Logcat for exception:
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): FATAL EXCEPTION: main
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): java.lang.NullPointerException
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
06-05 23:02:30.792: ERROR/AndroidRuntime(3905): at com.citsci.mardeb.Impacts.getImpacts(Impacts.java:79)