Jack Trowbridge
Jack Trowbridge

Reputation: 3251

android development eclipse (list activity)

It has the 'class' underlined in yellow and says its a warning saying that 'Class is a raw type. References to generic type Class should be parameterized'

Class ourClass = Class.forName("com.thenewboston.jack." + cheese); 

I have tried all the quick fixes and every thing. I don't know what to do. Could any one help and tell me what to do?


Here is the rest of the code and where the code is placed:

package com.thenewboston.jack;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;



public class Menu extends ListActivity{

 String classes[] = {"Startingpoint", "Example1", "Example2", "Example3"
            , "Example4", "Example5", "Example6", "Example7", "Example7",  "Example7"};

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_expandable_list_item_1, classes));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub

    super.onListItemClick(l, v, position, id);
    String cheese = classes[position];
    try{
    Class ourClass = Class.forName("com.thenewboston.jack." + cheese);
    Intent ourIntent = new Intent(Menu.this, ourClass);
    startActivity(ourIntent);
    }catch(ClassNotFoundException e){
        e.printStackTrace();
    }


}
}

Upvotes: 0

Views: 719

Answers (1)

Adil Soomro
Adil Soomro

Reputation: 37729

Modify like this

Class<Activity> ourClass = Class.forName("com.thenewboston.jack." + cheese);

or simply suppress this warnig using:

@SuppressWarnings("rawtypes")

above the line which is generating warning.

Upvotes: 2

Related Questions