• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with Cannot cast from View to ListView

Arehexes

Well-Known Member
Ok so I looked around and didn't see much on this but I'm getting this problem with my code

Code:
public class ListView extends Activity {
    
    String [] test=new String[100];
    ListView list;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.relative);
        
        for(int i=0; i<test.length; i++){
            test[i]="Line" +(""+(i+1));
        }
        
        list=(ListView)findViewById(R.id.listView1);
        
        ArrayAdapter adapt=new ArrayAdapter<String> (this, R.layout.textlist, test);
     }
}

The problem is this line right here

list=(ListView)findViewById(R.id.listView1);

which gives me a Cannot cast from View to ListView and I checked the xml file and it is a ListView so I don't know what the deal is. I was wondering if anyone knew
 
Back
Top Bottom