tags:

views:

64

answers:

1

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.

A: 

oh, sorry. I figured it out. I had imported the wrong items!

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 
import android.widget.TextView; 
import android.widget.Toast; 
import android.widget.AdapterView.OnItemClickListener;

That is what it should look like.

Keenan Thompson
this is what I like about eclipse :)
schwiz