I have an error that says "OnItemClickListener cannot be resolved to a type" when I enter this code in:
package com.funkystudios.android.facts;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class activity2 extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] Facts = getResources().getStringArray(R.array.Facts_Array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list, Facts));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();
}
});
}
}
It occurs right at the "lv.setOnItemClickListener(new OnItemClickListener() {". I'm not sure what I'm doing wrong.