Hello I'm new on android I have this trouble with my code
package com.example.spinner;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;
public class MainActivity extends Activity {
Spinner lista;
String[] datos = {"opcion1", "opcion2", "Ir a listView"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lista = (Spinner) findViewById(R.id.lista1);
ArrayAdapter<String> adaptador = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, datos);
lista.setAdapter(adaptador);
lista.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> adapterView, View view,
int i, long l) {
// TODO Auto-generated method stub
switch (i){
case 1:
Toast to = Toast.makeText(getApplicationContext(), datos[i], Toast.LENGTH_SHORT);
to.show();
break;
case 2:
Intent int = new Intent(MainActivity.this, VentanaListView.class);
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
}
}
In the switch case 2 is where a litte box appears saying :
Intent cannot be resolved to a variable
I have already import the Intent using import android.content.Intent;
and It says
The import android.content.Intent is never used
Please do you know what should I do?