Brandon Wiser
Brandon Wiser

Reputation: 23

The type of the expression must be an array type but it resolved to int

I get the following error in my android app:

The type of the expression must be an array type but it resolved to int

protected void onListItemClick(ListView lv, View v, int position, long id) {
    super.onListItemClick(lv, v, position, id);
    String openClass = R.array.calc_categories[position]; //error on this line
    try {
        Class selected = Class.forName("com.calculator.commonCalculatios." + openClass);
        Intent selectedIntent = new Intent(this, selected);
        startActivity(selectedIntent);

Upvotes: 0

Views: 1779

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234837

You probably want something like this:

String openClass = getResources().getStringArray(R.array.calc_categories)[position]

Upvotes: 1

Related Questions