EDIT: woah ... somehow i replaced this question with another one i was asking, glad there is this rollback feature
这一具体问题涉及从我的。
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);
}
(a) 具有这些错误之处:
Impacts(ContextWrapper).getResources() line: 80
Impacts.getImpacts() line: 78
the final bracket of the below code:
@Override
public Resources getResources()
{
return mBase.getResources();
}
以及这一条码:
impactsn = getResources().getStringArray(R.array.impacts);
这里是我方言。
<?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>
i 最初的项目为:
<item>Gas/Oil/Chemical Pollutants</item>
但确定,如果不解决问题,至少会改变错误。 但是,没有错误。 任何帮助都会受到广泛赞赏,不十分熟悉阵列的使用,特别是为阵列提供资源。
例外:
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)