This is the error I'm getting in logcat:
01-12 09:41:43.885: W/dalvikvm(1474): Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/app/Items;
This is my Home.java class which is the main activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
homeTextViews = new TextView[Items.HomeItem.length];
}
And here is the Item.java class:
public class Items {
public static final String[] HomeItem = new String[] { "string1", "string2", "string3" };
}
Upon starting the app I get the error said above as soon as it starts, the homeTextViews = new TextView[Items.HomeItem.length];
is the cause but I have no clue why. Anyone have any ideas?
I've also tried this but it still fails:
Items items = new Items();
homeTextViews = new TextView[items.HomeItem.length];
Items.HomeItem
clearly isn't null
, it's a static
final
so it shouldn't be null
.